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.

DarkBASIC Professional Discussion / Question about Find Sub String$ command

Author
Message
GregA
15
Years of Service
User Offline
Joined: 21st Jun 2011
Location:
Posted: 18th Jul 2012 10:35
When if fails to find a substring, rather than returning something I expect like -1 it returns a giant negative number like... -1232123 or something like that.

What does that number mean, if anything?
Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 19th Jul 2012 12:46 Edited at: 19th Jul 2012 12:48
It could be the decimal representation of one of the magic debug values or something similar. Possibly it's the signed representation of 0xffffffff (which would be the maximum value for an unsigned 32-byte integer) or something similar.

Edit: as long as its consistently negative you can check if the string exists using "if find substring(str$, substr$) > 0".


"Why do programmers get Halloween and Christmas mixed up?"
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 19th Jul 2012 21:09 Edited at: 19th Jul 2012 21:10
The value seems to depend on the input strings and on the ordering of the commands in some not very obvious way - but it does seem that the reported value is always negative when the string isn't present so your suggestion seems to be the way to do it. Perhaps it's a pointer value?

That's a good example of the sort of detail missing from the Help file.

Login to post a reply

Server time is: 2026-07-07 14:23:32
Your offset time is: 2026-07-07 14:23:32