Character comparison
St4rk
✭
in RobotStudio
Hello,
will I be able make similiar program like I done in C++ ?
Problem is that I don't know how should I comparison character in string in robotstudio. I try command TEST but there I can only comparison number.
Thanks for help.
will I be able make similiar program like I done in C++ ?
int main(){
string word = "car";
for(int i = 0; i < word.length(); i++) {
char x = word[i];
switch(x){
case 'c':
GOTO Path_10
break;
case 'a':
GOTO Path_20
break;
case 'r':
GOTO Path_30
break;
}
}
}
Problem is that I don't know how should I comparison character in string in robotstudio. I try command TEST but there I can only comparison number.
Thanks for help.
0
Comments
-
PERS string test_txt:="up";
PROC main()
TEST test_txt
CASE "up":
TPWrite "up";
CASE "down":
TPWrite "down";
DEFAULT:
TPWrite "other";
ENDTEST
ENDPROC
Use the string functions to manipulate your text and extract individual letters (see attached).
0 -
Thank you0
-
<div> PROC main()<br></div><div> VAR string x;<br></div><div> VAR string word := "car";<br></div><div> VAR num counter := 1;<br></div><div> <br></div><div> ! loop all chars<br></div><div> WHILE counter <= StrLen(word) DO<br></div><div> <br></div><div> ! get char<br></div><div> x := StrPart(word, counter, 1);<br></div><div> <br></div><div> ! switch based on char<br></div><div> TEST x<br></div><div> CASE "c": GOTO Path_10;<br></div><div> CASE "a": GOTO Path_20;<br></div><div> CASE "r": GOTO Path_30;<br></div><div> ENDTEST<br></div><div> <br></div><div> ENDWHILE<br></div><div> <br></div><div> ! dummy labels<br></div><div> Path_10:<br></div><div> Path_20:<br></div><div> Path_30:<br></div><div><br></div><div> ENDPROC</div>
0 -
I already solve my problem but thank you !0
Categories
- All Categories
- 5.5K RobotStudio
- 395 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