Hello, does anybody know how to pass a string parameter to a routine?
For example, something like that:
call Gripper('Open')
And in Gripper=
IF AR[1]='Open, JMP LBL[1]
Thank you!!
Hello, does anybody know how to pass a string parameter to a routine?
For example, something like that:
call Gripper('Open')
And in Gripper=
IF AR[1]='Open, JMP LBL[1]
Thank you!!
How you have it would work, at least partially. However the problem is that you can't assign string registers directly. Also in the IF statement you can't compare to a string literal.
You have to create a string assignment macro to do the assignment.
So to make your program work you would have to do the following:
And then in gripper:
/PROG GRIPPER
/ATTR
/MN
1: CALL STR_ASSIGN('Open') ;
2: !SR[1] is the temp string reg ;
3: IF SR[1]=AR[1], JMP LBL[1] ;
4: !Strings do not match. ;
5: UALM[1] ;
6: END ;
7: LBL[1:Strings Match] ;
8: !Do Gripper stuff. ;
/POS
/END
Display More
Which would have to call STR_ASSIGN for the IF statement in GRIPPER to work.
Another option similar to what Nation posted would be to set some String Registers equal to the strings you are looking for and compare them to the AR . I manually set SR[2] & SR[3] to OPEN and CLOSE in the DATA window. Then I ran a program that called the program below and it would jump to LBL[1] or LBL[2] depending on what string was passed to this program.
1: !ARGUMENT TEST FOR STRINGS ;
2: IF SR[2]=AR[1],JMP LBL[1] ;
3: IF SR[3]=AR[1],JMP LBL[2] ;
4: ;
5: ;
6: LBL[1] ;
7: ;
8: ;
9: ;
10: ;
11: LBL[2] ;
12: ;
13: ;
14: ;
15: ;