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:

tblaxland

O-F Administrator
Administrator
Addon Developer
Webmaster
Joined
Jan 1, 2008
Messages
7,320
Reaction score
25
Points
113
Location
Sydney, Australia
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
 

Juanelm

Addon Developer
Addon Developer
Donator
Joined
Nov 15, 2008
Messages
229
Reaction score
0
Points
16
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.
 

Quick_Nick

Passed the Turing Test
Donator
Joined
Oct 20, 2007
Messages
4,088
Reaction score
204
Points
103
Location
Tucson, AZ
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)
 

dbeachy1

O-F Administrator
Administrator
Orbiter Contributor
Addon Developer
Donator
Beta Tester
Joined
Jan 14, 2008
Messages
9,218
Reaction score
1,566
Points
203
Location
VA
Website
alteaaerospace.com
Preferred Pronouns
he/him
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.
 

Juanelm

Addon Developer
Addon Developer
Donator
Joined
Nov 15, 2008
Messages
229
Reaction score
0
Points
16
I will check those suggestions. Luckily the only tag in the keymap that would cause the problem is the HUD tag.
 
Top