Author Topic: Not set CMDSEGMENT text token yield "Not Set"  (Read 1433 times)

Egil Sandfeld

  • Newbie
  • *
  • Posts: 25
Not set CMDSEGMENT text token yield "Not Set"
« on: March 13, 2021, 05:11:58 AM »
Hi guys,

On my end for VA 1.8.7, I must compare a CMDSEGMENT token against "Not Set".

In other words, null values in CMDSEGMENT are actually not null but the typed string value of "Not Set".
So to make sure there's a real value in the CMDSEGMENT3 below, I have to check for it being set, not being blank/empty, and also check if it's not "Not Set". That seems wrong but works:


Begin Condition : ([{CMDSEGMENT:3}] Has Been Set AND [{CMDSEGMENT:3}] Does Not Equal '' AND [{CMDSEGMENT:3}] Does Not Equal 'Not Set')
    Set decimal [fuelAddDecimal] value to the converted value of {CMDSEGMENT:3}
End Condition


Maybe it's should just be blank if there are no values.
Perhaps the issue comes from a variation on the CMDSEGMENT:3 existence in the command string that I'm calling when the issue occurs:

Code: [Select]
Set fuel to [0..130] point [0..9] [pounds;gallons;];Set fuel to [0..130] [kilos;liters;pounds;gallons;]
Notice the second variation's segment 3 is [kilos;liters;pounds;gallons;], while the first has [0..9]

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Not set CMDSEGMENT text token yield "Not Set"
« Reply #1 on: March 13, 2021, 06:39:44 AM »
Have you read the documentation on these features?

Tokens always, without exception, return text. A null value (I.E. no value at all, not a NULL character) is not valid text, so it cannot be the output of a token.

Also, a token does not store a value, as it is not a variable. It returns a value stored elsewhere. Thus, it cannot be set or not set (those operators apply strictly to variables).


In addition, a blank value specifically represents an optional section that was not used, E.G. with a "When I say" value of "my [command;]", speaking "my" would have "{CMDSEGMENT:0}" return "my", "{CMDSEGMENT:1} return  "" (blank), and "{CMDSEGMENT:2} (as well as all subsequent segment tokens) return "Not set", to indicate there are no sections remaining (technically if you had a section the literally contained "not set", there would be no native way to distinguish between them, however that should be an edge case).