variable name + index

Hello,
is it possible to index variable names in rapid?
lets say the variable is defined as VAR num VarToIndex. How can I do in rapid something like VarToIndex+1:=5; VarToIndex+2:= … and so on?
Is it possible to do it also with strings? like VarToIndex+“A”:= …; VarToIndex+“B”:… ? I have been trying to figure out what the right syntax is for indexing with numbers but I can’t figure it out. I would be more interesting to index it with strings but if that is not possible numbers are just fine.

Thank you very much

If you want an index you should use an array as this
VAR num VarToIndex{Size}

then you would just type
VarToIndex{1}:=5;
VarToIndex{2}:=4;
etc…

I understand that but I have to do something like this:
I have multiple arrays that are defined like this:

PERS num bufferA{4,4}:=[[3,0,0,0],[0,0,2,1],[1,1,1,1],[1,1,1,1]];
PERS num bufferB{4,4}:=[[3,0,0,0],[2,1,1,1],[1,1,1,1],[1,1,1,1]];
PERS num bufferC{4,4}:=[[3,0,0,0],[2,1,1,1],[1,1,1,1],[1,1,1,1]];
… and so on

Then I need to call any of those buffers in a PROC

work with the values of that array and assign values again to that array. Something like this:

POC myprocedure (num buffer{,})
here I work with the buffer and need to asign values back to original array
for example

IF buffer{i,j}=2 THEN
bufferA{i,j}:=2

ENDIF

ENDPROC

I know I can pass another argument into procedure that will say if its buffer 1,2,3,4 … but how can I assign values into original array according to that number and make it unviersal for more arrays?

If I could create array of arrays I would know how to do that but I cant

Hi @sort
maybe I missing something in your question but if you have different variables named as varToIndex1, varToIndex2, varToIndex3, ecc.. you can easly access to them using the function SetDataVal.
So for example:
VAR num value:=3;

SetDataVal “varToIndex”+ValToStr(1),value;

Hope this help, U.

Similar to what @YuGo suggested, maybe you’re looking for something like GetDataVal.

PROC SetVarFromString()

VAR string pre:=“str”;

VAR string strA:="Hi, ";
VAR string strB:="How ";
VAR string strC:="are ";
VAR string strD:=“you?”;

VAR string outA;
VAR string outB;
VAR string outC;
VAR string outD;

GetDataVal pre+“A”,outA;
GetDataVal pre+“B”,outB;
GetDataVal pre+“C”,outC;
GetDataVal pre+“D”,outD;

TPWrite outA+outB+outC+outD;
WaitTime 1;

ENDPROC