Using Variables that Start with "@"

Started by mcjathan, February 25, 2017, 02:36:02 PM

Previous topic - Next topic

mcjathan

For some time, I've designated a certain self-created category of variables to start with the "@" symbol.  For example,

    @NTF_Symbols = "XXXXX,DFIHX"
    @DFA_TF = 9.99

These variables types seemed to have worked fine for many years, but I just ran into two situations where they don't work:

      If StrIndexNc(@NTF_Symbols, symbol, 1, @FWDSCAN) == 0 Then
          NTF_Symbol = @FALSE
      Else
          NTF_Symbol = @TRUE
      Endif

And:

       my_string = "Value is $%@DFA_TF%"

In both cases, Winbatch seems to be treating them as variables that do exist but are empty ("").

Please help me understand this.




td

Can't reproduce the problem but it is not a  good idea to use the "@" character as the first character of a variable name.  This is because WIL constants and WIL extender constants begin with the "@" character and you could run into name collisions.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

JTaylor

I tried them as well and they work for me.   Guessing you are doing something to clear them out unless you what you post fails for you as well.   Did you try the exact code you posted?

Code (winbatch) Select


    @NTF_Symbols = "XXXXX,DFIHX"
    @DFA_TF = 9.99

    symbol = 0
;These variables types seemed to have worked fine for many years, but I just ran into two situations where they don't work:

      If StrIndexNc(@NTF_Symbols, symbol, 1, @FWDSCAN) == 0 Then
          NTF_Symbol = @FALSE
      Else
          NTF_Symbol = @TRUE
      Endif

;And:

       my_string = "Value is $%@DFA_TF%"

message("HI",my_string)
message("HI",@NTF_Symbols)


Jim