WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: mcjathan on February 25, 2017, 02:36:02 PM

Title: Using Variables that Start with "@"
Post by: mcjathan on February 25, 2017, 02:36:02 PM
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.



Title: Re: Using Variables that Start with "@"
Post by: td on February 25, 2017, 04:56:18 PM
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.
Title: Re: Using Variables that Start with "@"
Post by: JTaylor on February 27, 2017, 07:13:59 AM
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