Error Problem with oapiReadItem_string

Juanelm

Addon Developer
Addon Developer
Donator
Joined
Nov 15, 2008
Messages
229
Reaction score
0
Points
16
I found an issue with oapiReadItem_string. Is this a known issue? Can someone replicate it? (Maybe I'm doing something wrong?) Thanks.

If I use oapiReadItem_string to scan a file for the tag "HUD", and this file does not contain the tag "HUD", but contains the tag "HUDMode", the function reads "HUDMode" and returns true, instead of returning false.
 
Last edited:
I can confirm it is a known behaviour. I just make sure that I don't have string patterns that will generate such matches. So instead of using:
Code:
HUD
HUDMode
HUDUnits
I would use:
Code:
HUDData
HUDMode
HUDUnits
 
Oh i see. The problem is I am reading from the keymap.cfg, and it has "HUD", as well as "HUDMode". Maybe I'll have to resort to another method for reading the file.
Thanks.
 
Oh i see. The problem is I am reading from the keymap.cfg, and it has "HUD", as well as "HUDMode". Maybe I'll have to resort to another method for reading the file.
Thanks.
Could you try also reading the space after it? (or even more if necessary)
 
Worst-case you can always use the Win32 API file functions to read the file you want directly; e.g., CreateFile, ReadFile, etc. That would be a bit more work because you'd have to parse the lines yourself, but then you could scan the file exactly like you want to.
 
I will check those suggestions. Luckily the only tag in the keymap that would cause the problem is the HUD tag.
 
Back
Top