kevilay2017

Indirect Address A Variable

4 posts in this topic

#1 ·  Posted

Hello Guys, What im trying to do is write a script that is doing the same thing  but with a bunch of different variables. Here is a rough example. I dont know how to indirectly address the variable

$Item0=0
$Item1=1
$Item1=2
$Indexer=0

While1
MsgBox(1,$Item[$indexer] ,$Item[$indexer])
$indexer = $indexer + 1
Wend

Basically everytime the indexer indexes, it would be looking at a different item variable. I know how to do this with PLCs, but not with this type of code. In PLC 's we call this indirect addressing. 

Share this post


Link to post
Share on other sites



#2 ·  Posted

Hello. Check Arrays in Help File.

 

Saludos

Share this post


Link to post
Share on other sites

#3 ·  Posted

Basic example:

;~ Declare variable as an array
Local $Item[3]
;~ Add value to each item in the array
$Item[0]=0
$Item[1]=1
$Item[2]=2

For $i = 0 To UBound($Item) - 1
    MsgBox(1,$Item[$i] ,$Item[$i])
Next

 

Share this post


Link to post
Share on other sites

#4 ·  Posted

This Is great thank you

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now