exit functions prematurely - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

exit functions prematurely

superjoe30superjoe30 Posts: 174Member
ditto.
How do I?
[hr]
[blue]Visual Basic[/blue]
~[b]Andy;-)[/b]~[italic]SuperJoe30:-([/italic]~
My Website:
http://www.geocties.com/joesarcade :-(
[red]JavaScript[/red]
[hr]

Comments

  • Secret_DoomSecret_Doom Posts: 116Member
    Hum... Perhaps you could put the entire function into a WHILE command. Then, in order to end it at any time, you would only have to change a variable:

    [code]

    function func1 () {
    while (run==1) {
    // ACTIONS
    }
    }

    run=1
    func1()
    [/code]

    To terminate that function, you would just have to 'run' to any other value than 1

    Is that what you wanted??

    -- Secret_Doom - Leonardo Pignataro --

    [email protected]
    www.batch.hpg.com.br

    : ditto.
    : How do I?
    : [hr]
    : [blue]Visual Basic[/blue]
    : ~[b]Andy;-)[/b]~[italic]SuperJoe30:-([/italic]~
    : My Website:
    : http://www.geocties.com/joesarcade :-(
    : [red]JavaScript[/red]
    : [hr]
    :

  • superjoe30superjoe30 Posts: 174Member

    : Is that what you wanted??
    :
    : -- Secret_Doom - Leonardo Pignataro --
    :
    Sure, but it seems like there would be a command for it.
    I will use your way, but if you find a command for it, please tell me!!!
    [hr]
    [blue]Visual Basic[/blue]
    ~[b]Andy;-)[/b]~[italic]SuperJoe30:-([/italic]~
    My Website:
    http://www.geocties.com/joesarcade :-(
    [red]JavaScript[/red]
    [hr]

  • YnotYnot Posts: 113Member
    :
    : : Is that what you wanted??
    : :
    : : -- Secret_Doom - Leonardo Pignataro --
    : :
    : Sure, but it seems like there would be a command for it.
    : I will use your way, but if you find a command for it, please tell me!!!
    : [hr]
    : [blue]Visual Basic[/blue]
    : ~[b]Andy;-)[/b]~[italic]SuperJoe30:-([/italic]~
    : My Website:
    : http://www.geocties.com/joesarcade :-(
    : [red]JavaScript[/red]
    : [hr]
    :
    :

    I haven't tried it myself but java has something called 'return'

    This MIGHT work:

    function int functionName(){
    :
    :
    if( I_want_to_exit == 1 )
    return 0;
    else{
    :
    :
    }

    // And you MUST include this at the end of the function
    return 0;
    // although the '0' can be replaced by any int value
    }

    As I said I don't know if it will work in javascript but it works in
    java...
    ____________________________

    Forever trust in who we are,
    And nothing else matters.
    -Metallica_
    ____________________________

Sign In or Register to comment.