I want to take a string that looks like this:
aaa123bbb456
and retrieve the number that comes right after "aaa", wherever "aaa" is and however long the number might be (123456, 12, etc.).
Can I rely on ToInt() (i.e., ToInt(10)) to always parse
"bbb" as 0
"bbb4" as 0
"123b" as 123
"123bbb456" as 123
etc.
so that I can just ToInt() whatever is to the right of "aaa" without checking where the consecutive numerals end?
Can I always rely on ToInt() to work like this?
Moderator: GZDoom Developers
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49234
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: Can I always rely on ToInt() to work like this?
Most of the time, yes, but beware of a few special cases:
0x???? gets interpreted as hex number.
124e45 may get converted to a float first. It shouldn't when using toInt, but I'd be careful with that.
0x???? gets interpreted as hex number.
124e45 may get converted to a float first. It shouldn't when using toInt, but I'd be careful with that.