viewpoint-particle

Author Topic: Using Variables that Start with "@"  (Read 447 times)

mcjathan

  • Newbie
  • *
  • Posts: 36
Using Variables that Start with "@"
« 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.




td

  • Tech Support
  • *****
  • Posts: 2140
    • WinBatch
Re: Using Variables that Start with "@"
« Reply #1 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.
"Success is a lousy teacher. It seduces smart people into thinking they can't lose."
  - Bill Gates


JTaylor

  • Pundit
  • *****
  • Posts: 748
    • Data & Stuff Inc.
Re: Using Variables that Start with "@"
« Reply #2 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

    @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