Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 procedure
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
w0lv3rin3




PostPosted: Wed Apr 23, 2003 6:27 pm   Post subject: procedure

what does procedure and noose do in turing?
Sponsor
Sponsor
Sponsor
sponsor
Blade




PostPosted: Wed Apr 23, 2003 6:39 pm   Post subject: (No 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
Catalyst




PostPosted: Wed Apr 23, 2003 6:42 pm   Post subject: (No subject)

whats a noose?
Homer_simpson




PostPosted: Wed Apr 23, 2003 6:43 pm   Post subject: (No 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
Catalyst




PostPosted: Wed Apr 23, 2003 6:44 pm   Post subject: (No subject)

but what a noose?
Homer_simpson




PostPosted: Wed Apr 23, 2003 6:51 pm   Post subject: (No subject)

i think he's made a spelling mistake =/
w0lv3rin3




PostPosted: Wed Apr 23, 2003 7:01 pm   Post subject: (No subject)

forget about noose, was not ment to be their

thx alot
Mazer




PostPosted: Thu Apr 24, 2003 7:14 am   Post subject: (No 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
Sponsor
Sponsor
Sponsor
sponsor
Blade




PostPosted: Thu Apr 24, 2003 7:37 am   Post subject: (No subject)

then i should be dead..
w0lv3rin3




PostPosted: Thu Apr 24, 2003 7:41 am   Post subject: (No subject)

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




PostPosted: Thu Apr 24, 2003 8:36 am   Post subject: (No subject)

I never bought mine haha
Delta




PostPosted: Thu Apr 24, 2003 8:38 am   Post subject: (No subject)

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




PostPosted: Thu Apr 24, 2003 9:44 am   Post subject: (No subject)

java is free dude
Lone]2




PostPosted: Thu Apr 24, 2003 9:53 am   Post subject: (No subject)

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



Twisted Evil
tomako




PostPosted: Thu Apr 24, 2003 9:55 am   Post subject: (No 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 ....
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 16 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: