Computer Science Canada Run Code from Specific Line? |
Author: | user23 [ Sun May 22, 2011 12:44 pm ] |
Post subject: | Run Code from Specific Line? |
Sorry for all these threads lately, hopefully this is the last. Is it possible to do something where it goes back to a specific line of code (or the beginning)? Procedures wont work since some of mine have to be in specific orders, contain variables that the rest needs, etc. Basically I want to do something like if X = 1 then go back to line 1 (or any value here) end if Is something like that possible? Thanks |
Author: | RandomLetters [ Sun May 22, 2011 12:58 pm ] |
Post subject: | RE:Run Code from Specific Line? |
It's possible. Although arguably, you shouldn't use it. http://compsci.ca/v3/viewtopic.php?t=370 GoTos are at the bottom section. |
Author: | apython1992 [ Sun May 22, 2011 1:48 pm ] |
Post subject: | RE:Run Code from Specific Line? |
If you're wanting to reuse certain pieces of code under conditions, consider using functions and procedures. They let you define pieces of code that act to carry out some function, which you can use over and over again by calling the procedure/function. |
Author: | SmokeMonster [ Sun May 22, 2011 6:16 pm ] |
Post subject: | Re: Run Code from Specific Line? |
I suggest you re-examine your code and see if you can find a better way to design your program to accomplish what you are trying to do. What you're saying wreaks of Code smell http://en.wikipedia.org/wiki/Code_smell |