[ZScript] String.Search(<string>)

Moderator: GZDoom Developers

Post Reply
User avatar
Major Cooke
Posts: 8175
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

[ZScript] String.Search(<string>)

Post by Major Cooke »

Yes, it is possible to manually search for certain keywords within ZScript. However, this means manually adjusting a for loop inside of ZScript to find the arrangement of letters we're looking for, and I'm pretty positive on ZScript's side, that's one heck of a slowdown.

In case if some don't know what I'm talking about, say I have a sentence "IWantTacos" and I want to find the word "Tacos" within. An official native implementation of this sounds like a much saner and less laggier comparison than manually doing it in a for loop.

(I could be wrong -- there could possibly be no difference, but I can't say for certain. However, this is the VM doing the work instead of the engine so I'm assuming it'd be more performance efficient to have it all done natively and returned.)
_mental_
 
 
Posts: 3812
Joined: Sun Aug 07, 2011 4:32 am

Re: [ZScript] String.Search(<string>)

Post by _mental_ »

I think it's better to add existing IndexOf() and LastIndexOf() functions from C++ FString class to ZScript because they are much more versatile.
User avatar
Major Cooke
Posts: 8175
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: [ZScript] String.Search(<string>)

Post by Major Cooke »

Whatever works best!
_mental_
 
 
Posts: 3812
Joined: Sun Aug 07, 2011 4:32 am

Re: [ZScript] String.Search(<string>)

Post by _mental_ »

It's not a big deal to add them. But what will be the next version of ZScript? 2.6?
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49067
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: [ZScript] String.Search(<string>)

Post by Graf Zahl »

New functions do not require a new version, only changes that may break existing code. In any case, the ZScript version should be the same as the engine version, the next one would be 3.2
_mental_
 
 
Posts: 3812
Joined: Sun Aug 07, 2011 4:32 am

Re: [ZScript] String.Search(<string>)

Post by _mental_ »

Added in c56cd24. Both function will return -1 if search string was not found.
User avatar
Rachael
Posts: 13559
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her
Contact:

Re: [ZScript] String.Search(<string>)

Post by Rachael »

Graf Zahl wrote:New functions do not require a new version, only changes that may break existing code. In any case, the ZScript version should be the same as the engine version, the next one would be 3.2
The ZScript.txt file still specifies "2.5" (and was actually a source of confusion when I corrected the version.h comment, Major Cooke thought I changed it to the wrong version).

I didn't bother changing it though since no breaking changes were introduced - as far as I know.
Post Reply

Return to “Closed Feature Suggestions [GZDoom]”