Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Run Code from Specific Line?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
user23




PostPosted: 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
Sponsor
Sponsor
Sponsor
sponsor
RandomLetters




PostPosted: 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.
apython1992




PostPosted: 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.
SmokeMonster




PostPosted: 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
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: