loading
 
VB Script GOTO command not working
AIMan from United States  [1 posts]
12 year
I am on a team working on getting VB Script to work with RoboRealm. The problem isnt' getting the scripte to run the problem is that the GOTO statement doesn't work which neccisitates a lot of extra code being read.

The second problem is that the motor that is set with the VB code stutters because the variables are declared each time the code runs.

How can I implement a GOTO command to avoid the extra code and how can I change the code so the variables don't re-initalize and make the motor stutter?

Originally I was going to do a if goto end if statement but that isn't working.
Steven Gentner from United States  [1446 posts] 12 year
AIMan,

While it initially seems like a bad idea, its best NOT to use any gotos in any code that you write. It creates the proverbial "spaghetti" code. It is always possible to create loops and conditions to avoid using gotos and the code is normally much better of for that. I'd focus on how to rewrite the code without using gotos ... there is a reason that most of the modern languages do not support that. If you need help with that just post the code here and I'm sure many of the viewers would be able to help modernize that code.

The VBScript module is called anew each time it is executed. The variables will not retain state unless you save them. So use

var = GetVariable("var")

...

SetVariable "var", var

for int, float and

var = GetStrVariable("var")

...

SetStrVariable "var", var

for strings in order to save the variables and resume them. Keep in mind that the VBScript module is within the pipeline loop. So if you stall that module the entire pipeline is stalled. To remedy this, use a state variable to let you know what you were last doing.

STeven.

This forum thread has been closed due to inactivity (more than 4 months) or number of replies (more than 50 messages). Please start a New Post and enter a new forum thread with the appropriate title.

 New Post   Forum Index