
proc argument
pab
✭
Hi!
Please tell me why it works with num, but does not work with string?
it work:
PROC main
test 1;
test 2;
ENDPROC
PROC test (num x)
IF x = 1 THEN
...
ELSEIF x = 2 THEN
...
ENDIF
ENDPROC
it will be error:
PROC main
test first;
test second;
EMDPROC
PROC test (string x)
IF x = first THEN
...
ELSEIF x = second THEN
...
ENDIF
ENDPROC
Please tell me why it works with num, but does not work with string?
it work:
PROC main
test 1;
test 2;
ENDPROC
PROC test (num x)
IF x = 1 THEN
...
ELSEIF x = 2 THEN
...
ENDIF
ENDPROC
it will be error:
PROC main
test first;
test second;
EMDPROC
PROC test (string x)
IF x = first THEN
...
ELSEIF x = second THEN
...
ENDIF
ENDPROC
0
Best Answers
-
Don't use "test" as proc identifier. It looks like it's reserved.
This syntax seems to work:
PROC abc(string x)IF x="first" THENELSEIF x="second" THENENDIFENDPROCPROC abcd(num x)IF x=2 THENELSEIF x=3 THENENDIFENDPROC
—Maxim RiabichevPC Software Support Engineer0 -
Also your syntax when calling:
Test "first";
To indicate that it is passing a string into the procedure.
And, same as Maxim's example, you need to have the quotation marks to indicate string data type:
IF x = "first" THEN
UNLESS it is the name of an already declared string data.Lee Justice0
Answers
-
The quotation marks. Here's what I missed when working with string. Thanks!lemster68 said:Also your syntax when calling:
Test "first";
To indicate that it is passing a string into the procedure.
And, same as Maxim's example, you need to have the quotation marks to indicate string data type:
IF x = "first" THEN
UNLESS it is the name of an already declared string data.
p.s.
I used "test" just for the sample code0
Categories
- All Categories
- 5.6K RobotStudio
- 401 UpFeed
- 21 Tutorials
- 15 RobotApps
- 306 PowerPacs
- 407 RobotStudio S4
- 1.8K Developer Tools
- 250 ScreenMaker
- 2.9K Robot Controller
- 364 IRC5
- 82 OmniCore
- 8 RCS (Realistic Controller Simulation)
- 853 RAPID Programming
- 35 AppStudio
- 4 RobotStudio AR Viewer
- 19 Wizard Easy Programming
- 110 Collaborative Robots
- 5 Job listings

