[thelist] JS: Exiting a Function

Syed Zeeshan Haider szh at softhome.net
Sun Feb 2 14:46:00 CST 2003


From: ".jeff"
To: <thelist at lists.evolt.org>
Sent: February 03, 2003, Monday 1:14 AM
Subject: RE: [thelist] JS: Exiting a Function

> i guess what i'm getting at is there isn't really a way to make a function
> that doesn't return anything at all.
>
> can you explain in greater detail what you're trying to do?

Thanks for your response, Jeff.

In fact, I would not have asked this if I had not been learning VB. In VB, "Exit
Sub" is used to exit a procedure when no more execution is needed. Today while
amending my own written script I found that if I had something like "Exit Sub"
in JS, my script would have been a lot simpler.
I want to exit the function when a certain condition has been satisfied.

var st = 1
function ColourText()
{


if (st == 1)
    {
      text.style.color = "red"
// here I want to exit the function if var == 1
     }

if (st == 2)
    {
      text.style.color = "blue"
// here I want to exit the function if var == 2
     }

// and some more statements ....

}  // function's end

Is there anything in JS like "Exit Sub" of VB for above-mentioned situations.

Thank you,
Syed Zeeshan Haider.
http://syedzeeshanhaider.faithweb.com/




More information about the thelist mailing list