[SOLVED] Using Dynamic Variable Names

You edit your post, but is still full of frills and errors.

If you try to correct someone who corrects you, at least make sure you correct well…
If 2 is a number there is no need for “”, if instead it is a string, then consistently the 1 must also be quoted…
And about "check$nwsarr" must be, for the same reason, :set "check$nwsarr" and :set "Down$nwsarr"
I do not have added " (on all places) for not add unreadability on code.
Since someone is not so dumb to use problematic variable names… Or not?


Rightly so, what @Amm0 says is correct.
Without parse, execute and other frills…
{

:global gev
:if ([:typeof [$gev]] = “nil”) do={:global gev [:toarray “”]}

/system clock
:local datetime “$[get date] $[get time]”
:local nwshost (“Tes1”,“Tes2”,“Tes3”,“Tes4”,“Tes5”,“Tes6”,“Tes7”,“Tes8”,“Tes9”)
:local id (1 + [:len $nwshost])

added for test

:set ($gev->“checkTes2”) 1 ; # for test if work (($gev->“checkTes2”) != 1)

:foreach item in=$nwshost do={
:if (($gev->“check$item”) != 1) do={:set ($gev->“check$item”) 2}
:set ($gev->“Down$item”) $datetime
}

added for test

:put ($gev->“checkTes2”)
:put ($gev->“DownTes2”)
:put ($gev->“checkTes4”)
:put ($gev->“DownTes4”)

}