RAPID: use string as argument name
in RobotStudio
I'm looking for a way to produce the reverse of ArgName(anytype)
Rather than getting the name of an argument as a string, I'd like to use a string as the name of an argument.
VAR num MyArg1 := 5;
VAR string Arg_string := "MyArg1";
I'd like to be able to use the value of Arg_string within code to call up the value of MyArg1, similar to how it's possible to call a procedure named by a string by surrounding the string argument name with %
VAR string CallProc := "SomeProcedure";
%CallProc%
This code would execute the procedure named "SomeProcedure"
I'm trying to do the same thing with the names of variables.
Alyssa Wells2013-02-28 18:41:00
0
Comments
-
To my knowledge, late binding is available for procedure calls only, see the RAPID Overview manual. Perhaps you can workaround it by creating procedures that act as variables, see my example below
[CODE]MODULE MyModule
VAR num myarg1:=0;
PROC ProcMyArg1(INOUT num outparameter)
outparameter:=5;
ENDPROC
PROC main()
VAR string CallProc:="ProcMyArg1";
%CallProc% myarg1;
TPWrite "The value of " + CallProc + " is " + NumToStr(myarg1,0);
ENDPROC
ENDMODULE[/CODE]
Output:
Henrik Berlin2013-03-01 07:48:51Henrik Berlin
ABB0 -
HiI think GetDataVal and SetDataVal instructions are what you are looking for. With these instructions you can get and set the value of the variable based on the name given in the string.-Osku1
-
Thanks osku, exactly what i was looking for.
0
Categories
- All Categories
- 5.5K RobotStudio
- 396 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 249 ScreenMaker
- 2.7K Robot Controller
- 310 IRC5
- 59 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 785 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 4 Job listings