
-----------------------------------
greenapplesodaex
Tue Jun 08, 2004 8:48 pm

how do i stop a procedure?
-----------------------------------
Can I exit a procedure like exiting a loop?

-----------------------------------
aside
Tue Jun 08, 2004 8:49 pm


-----------------------------------
use return.

-----------------------------------
greenapplesodaex
Tue Jun 08, 2004 8:53 pm

reply
-----------------------------------
so... if i use return, will the program still shut down?

it said
procedure double
            if errorHasOccurred then
                return  % Terminate this procedure
            end if
            "¦ handle usual case in this procedure "¦
        end double

what's "errorHasOccurred", turing gave me an error on that

-----------------------------------
aside
Tue Jun 08, 2004 8:57 pm


-----------------------------------
or you can use "exit" if you are using a loop, if you are not sure. personally i have never use return before, i always use exit

-----------------------------------
greenapplesodaex
Tue Jun 08, 2004 9:08 pm

reply
-----------------------------------
i know how to exit a loop
i'm asking how to stop a procedure

take a look at this code, can you tell me y it doesnt work?
var errorOccurred : boolean := false

procedure double
    if Error.Last = eNoError then
    else
        errorOccurred := true
        put "error"
    end if

    if errorOccurred = true then
        put "error"
        return
    end if
end double

for i : 1 .. 300
    double
    colour (i)
    double
    put i, " " ..
    double
end for

-----------------------------------
TheZsterBunny
Thu Jun 10, 2004 5:25 pm


-----------------------------------
use return.

imagine your procedure like a loop.

now sub exit for return

its like the result command in functions. it quits the procedure, and continues along the mainline. if you use return not in a procedure, it quits your prog.

-Z
