Computer Science Canada

procedure

Author:  w0lv3rin3 [ Wed Apr 23, 2003 6:27 pm ]
Post subject:  procedure

what does procedure and noose do in turing?

Author:  Blade [ Wed Apr 23, 2003 6:39 pm ]
Post subject: 

dammit, tony plz put something up about telling ppl to check the tutorial section before asking questions....
look in here man
http://www.compsci.ca/bbs/viewforum.php?f=3

Author:  Catalyst [ Wed Apr 23, 2003 6:42 pm ]
Post subject: 

whats a noose?

Author:  Homer_simpson [ Wed Apr 23, 2003 6:43 pm ]
Post subject: 

procedure
it's basicly a declaration command that let's you make your own procedure
this is how it works

code:
procedure testproc(x,y,z:int) %declares testproc as a procedure with parameteres x,y,z
put x+y+z
end testproc

%main program
testproc(1,3,5)

the out put of this program will be 9

Quote:
procedure declaration

Syntax A procedureDeclaration is:
procedure id [(paramDeclaration {, paramDeclaration })]
statementsAndDeclarations
end id



Description A procedure declaration creates (but does not run) a new procedure. The name of the procedure (id) is given in two places, just after procedure and just after end.

Example
procedure greetings
put "Hello world"
end greetings

greetings % This outputs Hello world

procedure sayItAgain ( msg : string, n : int )
for i : 1 .. n
put msg
end for
end sayItAgain

sayItAgain ("Toot", 2 ) % Toot is output twice

procedure double ( var x : real )
x := 2 * x
end double

var y : real := 3.14
double ( y ) % This doubles the value of y

Details The set of parameters declared with the procedure are called formal parameters. In the double procedure, for example, x is a formal parameter. A procedure is called (invoked) by a procedure call statement which consists of the procedure's name followed by the parenthesized list of actual parameters (if any). For example, double(y) is a call having y as an actual parameter. If there are no parameters (see the greet procedure above), the call does not have parentheses. The keyword procedure can be abbreviated to proc.
Ordinarily, a procedure returns (finishes and goes back to the place where it was called) by reaching its end. However, the return statement in a procedure causes it to return immediately. Note that return can also be used in the main program to cause it to halt immediately.

Only parameters declared using var may be changed in the procedure, for example, x is changed in the double procedure. The upper bounds of arrays and strings that are parameters may be declared to be an asterisk (*). This means that the bound is that of the actual parameter. See paramDeclaration for details about parameters.

Procedures and functions cannot be declared inside other procedures and functions.

The syntax of a procedureDeclaration presented above has been simplified by leaving out the optional import list, pre condition, init clause, post condition and exception handler. The full syntax is


procedure [ pervasive ] id
[ ( [ paramDeclaration {,paramDeclaration } ] ) ]
[ : deviceSpecification ]
[ pre trueFalseExpn ]
[ init id := expn {, id := expn } ]
[ post trueFalseExpn ]
[ exceptionHandler ]
statementsAndDeclarations
end id
A procedure must be declared before being called. To allow

Author:  Catalyst [ Wed Apr 23, 2003 6:44 pm ]
Post subject: 

but what a noose?

Author:  Homer_simpson [ Wed Apr 23, 2003 6:51 pm ]
Post subject: 

i think he's made a spelling mistake =/

Author:  w0lv3rin3 [ Wed Apr 23, 2003 7:01 pm ]
Post subject: 

forget about noose, was not ment to be their

thx alot

Author:  Mazer [ Thu Apr 24, 2003 7:14 am ]
Post subject: 

nooses are used to hang people. maybe holtsoft should give those out with copies of turing so people can hang themselves are wasting their money... um, that is if you bought turing Wink

Author:  Blade [ Thu Apr 24, 2003 7:37 am ]
Post subject: 

then i should be dead..

Author:  w0lv3rin3 [ Thu Apr 24, 2003 7:41 am ]
Post subject: 

hahaha, i never baught mine, hehee, suckers who baught it

Author:  Miko99 [ Thu Apr 24, 2003 8:36 am ]
Post subject: 

I never bought mine haha

Author:  Delta [ Thu Apr 24, 2003 8:38 am ]
Post subject: 

I didn't buy my turing either but I did pay for my Java

Author:  w0lv3rin3 [ Thu Apr 24, 2003 9:44 am ]
Post subject: 

java is free dude

Author:  Lone]2 [ Thu Apr 24, 2003 9:53 am ]
Post subject: 

=S
u mean uy gotta PAY for turing???!!!!
Rolling Eyes



Twisted Evil

Author:  tomako [ Thu Apr 24, 2003 9:55 am ]
Post subject: 

u can get EVERYTHING free these days....

Turing is free.... Java is ALSO free....

our school practically gives it out Razz
even if they don't, da interent pwns u wif free d/ls ....

Author:  Tony [ Thu Apr 24, 2003 9:56 am ]
Post subject: 

well schools are SUPPOST go give them out. I donno why some have distribution license and some dont. They're all run by same education ministry Confused

and hey, you can always just copy the files from school, there's no system files hidden or anything, dont even have to install it.


: