Home

News

International

Screen Shots

Documentation

Download

Build

License

Credits

Contact

SourceForge Project

Tintware Documentation : Tint Programming Language : Tint Reference : Procedures : proc

Syntax

#(proc,%name,%body)
#(proc,%name,%body,%filename,%offset)
#(proc,%name,%body,%filename,%offset,%arg1,...)
#(proc,%name,%body,%filename,%offset,~arg1,...)

%name is the name of the procedure to be defined. %body is the body for the procedure. %filename optionally specifies the name of the file where the procedure is defined. %offset optionally specifies the offset into the file where the procedure is defined. %arg1 is the literal string indicating zero or more locations in the body where the first parameter should be substituted when the procedure is called. ... means there can be as many different arguments as you want. Arguments which begin with tilde (~) will be substituted as data when the procedure is called.

A new procedure will be created with the specified name. If an object with the specified name already exists, it will be freed before the new procedure is created.

There is no limit on the number of paramaters; however, there is a limit of 1024 substitutions. This means you can have a single parameter which gets substituted in up to 1024 different places in the body of the procedure, or 1024 different parameters each of which get substituted once, or anything in between.

%%argc is a special parameter. If it is in the body of any procedure it gets substituted for the number of arguments in the call to the procedure. This is done dynamically at call time.

Calling a procedure is one of the few places that it makes a difference whether an active call, eg. #(%name), or a passive call, eg. ##(%name), is used.

Example

#(proc,a-procedure,(#(+,%arg1,%arg2)),,,%arg1,%arg2)

#(a-procedure,1,2)
3
##(a-procedure,1,2)

                        #(+,1,2)
##(a-procedure,abc,def)

                            #(+,abc,def)
#(proc,a-procedure,(%%argc))

#(a-procedure)
0
#(a-procedure,a,b,c,d,e,f)
6
#(proc,a-procedure,(~param),,,~param)

#(a-procedure,(--,--))
--,--