[SOLVED][1.3b87] "true" as leading part of variable name

Confirmed bugs should get a single post here. Check the READ ME FIRST sticky thread for the format.

Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice, MapTool BugReport Manager

Forum rules
Posts that do not conform to the READ ME FIRST sticky thread are subject to deletion.
Post Reply
User avatar
lmarkus001
Great Wyrm
Posts: 1867
Joined: Sat Mar 29, 2008 12:30 am
Location: Layfayette Hill, PA

[SOLVED][1.3b87] "true" as leading part of variable name

Post by lmarkus001 »

Synopsis:
If you use a variable name that begins with "true", you will encounter failures or odd behavior.

Simple code sample:

Code: Select all

[ trueseeing = "asdf" ] 
Output in chat =

Code: Select all

Unknown node type: name=true, type=31


Sample Code: (this can be put into a Global macro and does not need a token to run)

Code: Select all

[H: sensesFixed = '["arcane sight","keen scent","lifesense","low-light vision","scent","see in darkness","see invisibility","snow vision","spiritsense","seeing - true","tr seeing","true seeing","unknown"]' ]

[H: inSenses = "tab01 | Senses | | TAB" ]
[H: inStringSensesFixed = "%{senseFv}|0|%{senseF}|CHECK|" ]

[H, FOREACH( senseF, sensesFixed ), CODE: {
   [ senseFv = replace(senseF, "[^a-zA-Z]", "") ]
   [ inSenses = listAppend( inSenses, strformat( inStringSensesFixed ), "##" ) ]
}]

[H: cancel = input(
inSenses
)]
[H: abort(cancel)]


[H: wSensesFixedJ = '[]' ]
[H, FOREACH( senseF, sensesFixed ), CODE: {
   [H: senseFv = replace(senseF, "[^a-zA-Z]", "") ]
   [ senseValue = eval(senseFv+"")]
   [IF(senseValue > 0): wSensesFixedJ = json.append( wSensesFixedJ, senseF ); "" ]
}]
[R: wSensesFixedJ ] 
Note that when this is run, you will ALWAYS get "true seeing" returned as checked.

Yes, I lost a LOT of hair with this one...
Last edited by lmarkus001 on Mon Jul 01, 2013 11:53 am, edited 1 time in total.

User avatar
lmarkus001
Great Wyrm
Posts: 1867
Joined: Sat Mar 29, 2008 12:30 am
Location: Layfayette Hill, PA

Re: [1.3b87] "true" as leading part of variable name

Post by lmarkus001 »

Now that I understand this more fully, I am not certain it is actually a "bug". More of a limitation.

It just bit me hard as it occurred based on data I entered (specifically "true seeing"). I could not believe that basic text could blow things up so badly, but in fact it sure can if you are then turning that text into variable names!

User avatar
lmarkus001
Great Wyrm
Posts: 1867
Joined: Sat Mar 29, 2008 12:30 am
Location: Layfayette Hill, PA

[SOLVED][1.3b87] "true" as leading part of variable name

Post by lmarkus001 »

My solution is to prepend a "z" (gimp but efficient).



Sample Code: (this can be put into a Global macro and does not need a token to run)

Code: Select all

[H: sensesFixed = '["arcane sight","keen scent","lifesense","low-light vision","scent","see in darkness","see invisibility","snow vision","spiritsense","seeing - true","tr seeing","true seeing","unknown"]' ]

[H: inSenses = "tab01 | Senses | | TAB" ]
[H: inStringSensesFixed = "%{senseFv}|0|%{senseF}|CHECK|" ]

[H, FOREACH( senseF, sensesFixed ), CODE: {
   [ senseFv = "z" + replace(senseF, "[^a-zA-Z]", "") ]
   [ inSenses = listAppend( inSenses, strformat( inStringSensesFixed ), "##" ) ]
}]

[H: cancel = input(
inSenses
)]
[H: abort(cancel)]


[H: wSensesFixedJ = '[]' ]
[H, FOREACH( senseF, sensesFixed ), CODE: {
   [H: senseFv = "z" + replace(senseF, "[^a-zA-Z]", "") ]
   [ senseValue = eval(senseFv+"")]
   [IF(senseValue > 0): wSensesFixedJ = json.append( wSensesFixedJ, senseF ); "" ]
}]
[R: wSensesFixedJ ] 
Last edited by lmarkus001 on Mon Jul 01, 2013 1:20 pm, edited 2 times in total.

User avatar
Bone White
Great Wyrm
Posts: 1124
Joined: Tue Aug 23, 2011 11:41 am
Location: Cornwall, UK

Re: [SOLVED][1.3b87] "true" as leading part of variable name

Post by Bone White »

lmarkus001 wrote:Yes, I lost a LOT of hair with this one...
http://forums.rptools.net/viewtopic.php?f=3&t=23931

Posted just a day earlier. You're not the only one who's lost hair because of this "feature".


Post Reply

Return to “Bug Reports”