Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
My input would be "F100S20>60" F100 would move the turtle forward 100, S20 would draw a circle with the radius of 20, and >60 would rotate the turtle. I cant figure out how to move along with the string and get the different commands from each part.

What I have tried:

I have a function set up that can execute one single command such as "F30" but that is it.
Posted
Updated 9-Oct-18 21:23pm

1 solution

If you know the structure of the command then it should be easy to split it into its constituent tokens. You can use substring notation if each part is fixed length or regexes if they are variable. Alternatively you can use string searching to find specific field delineators. Once you have the separate tokens you can use a simple loop to execute each part, by checking its control character and using its numeric value as data.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900