Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Jumping to different blocks of code

Status
Not open for further replies.

leegold2

Technical User
Oct 10, 2004
116
I can't off hand think of a way to this...say I have the standard:
if (boolean test)
....code block1...
else
...code block2...

now say I am in codeblock1 and I want to jump to codeblock2 (kinda like a goto) how couild I do this (w/out a goto)?

Thanks,
Lee G.
 
Turn code block 1 in to a function and invoke it the "else" stream.

Code:
function codeblock1()
{
//....
}

function codeblock2()
{
//----
}

if (boolean) {
   codeblock1(); }
else {
   codeblock2();
   codeblock1();
}

Ken
 
RIght, thanks. i'm seeing that functions can do what I want...thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top