Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / AGK2 - No INSTR command?

Author
Message
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 8th Dec 2014 09:31
Maybe it's called something else and hidden in the help files somewhere other than in the string section?

Anyone know if INSTR is included under another name?
If not, it appears to be a glaring omission!
=PRoF=
22
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 8th Dec 2014 09:34
What does that command do?

Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 8th Dec 2014 09:40
From Microsoft Visual BASIC help

It has a similar functionality in DBP but I can't find it in AGK.
I'm trying to write an XML parser but it isn't easy without INSTR.
=PRoF=
22
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 8th Dec 2014 09:58 Edited at: 8th Dec 2014 10:17
Nice, that seems like a handy command. I'm not aware of anything like that in AppGameKit, but equally, I wasn't aware that DBP could do it either.

I think you're just going to have to write a function to do it. I wrote a basic CSV parser a while back (before AppGameKit had the GetStringToken() commands) but I gave up with trying to do it with XML.

>Edit<

Here you go, a quick approximation of the InStr() command



It assumes you have these constants declared.



Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 8th Dec 2014 10:22 Edited at: 8th Dec 2014 12:43
You beat me to it!

I just popped back in to offer my solution but found yours instead. Mine is very similar so no point posting both of them.

Thanks

[EDIT]
Change of mind - no harm in offering two solutions should anyone else need it:



[EDIT2]
A slight update.
In an ideal world we would be able to overload functions in AppGameKit but since we can't then the following code will require all four parameters even if you don't need the last two:

With the update (above) you can specify the starting search position within your source string and also ignore (or not) case sensitivity.

Whilst the above function works perfectly it would still be nice to have the command included in AGK.

Login to post a reply

Server time is: 2025-05-24 00:15:43
Your offset time is: 2025-05-24 00:15:43