variable name + index
sort
✭
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
0
Comments
-
If you want an index you should use an array as thisVAR num VarToIndex{Size}then you would just typeVarToIndex{1}:=5;VarToIndex{2}:=4;etc...
0 -
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 onThen I need to call any of those buffers in a PROCwork 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 arrayfor exampleIF buffer{i,j}=2 THENbufferA{i,j}:=2ENDIFENDPROCI 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?
0 -
If I could create array of arrays I would know how to do that but I cant
0 -
Hi @sortmaybe 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.0
-
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
0 -
sort said: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 am understanding you...Maybe you should look at the INOUT parameter for a routine.
Lee Justice0
Categories
- All Categories
- 5.5K RobotStudio
- 396 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 250 ScreenMaker
- 2.8K Robot Controller
- 316 IRC5
- 61 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 798 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 5 Job listings