[EMAIL PROTECTED] schrieb:
> Hi its me again (the pane in the ass newbie)
>
> Where can i get a basic user guide, better yet a sam userguide ?
>
> i noticed the existence of a def proc in basic can anyone tellme how it works
> is it alá qbasic stile ?
>
>
>
> thanks

Hi dirty fly,
maybe a bit of an answer for you, extracting from Sam Supplement 5. It 
describes 
how to use DEF PROCedures. Hopes it helps you.
Have a nice day
Wo from WoMo-Team


DEF PROC (Martin Vale, SAM Supplement 5)

The DEFine PROCedure command precedes a block of  BASIC instructions that are 
separate from the rest of the program. Procedures work like GOSUBs. But whereas 
GOSUB n would execute the subroutine starting at line n, and then return to the 
statement after the GOSUB instruction when it encounters a RETURN, procedures 
can have values sent to them in the instruction that called them. For example, 
SQUARE 3. This would search through the BASIC program for a  procedure named 
SQUARE, carry it out, and return when it reached END PROC. In this example, the 
procedure SQUARE might simply be DEF PROC SQUARE,x (x being the value sent to 
it): LET x=SQR x: END PROC. This line could be placed anywhere in the BASIC 
program. Supposing line 10 was 10 SQUARE 3, the following line might be 20 
PRINT 
x. In this case it would print the square root of 3 (about 2.326). Of course, 
procedures do not have to have values sent to them. You could have a procedure 
called WAIT that just consisted of DEF PROC WAIT: PAUSE: END PROC, or a 
procedure called MATHS which needed 4 variables sent to it eg. a,b,c and d, 
where the procedure reads DEF PROC MATHS,a,b,c,d: LET answer=a+b*c-d: END PROC. 
Procedures don't have to be all squashed up on one line. They can contain any 
number of statements, IF's, GOTO's, GOSUB's, and can even call other procedures.
DEFAULT is a command used only inside procedures. It sets a default value for a 
variable, which is used if no value is sent to the procedure. For example, a 
procedure called PROMPT might be DEF PROC PROMPT,a,b: DEFAULT a,0.1: DEFAULT 
a,20:BEEP b,a: END PROC. If this were called with just PROMPT, it would carry 
out BEEP 0.1,20, if called with PROMPT 10, it would carry  out BEEP 10,20, and 
if it should be called with PROMPT 10,0, it would carry out BEEP 10,0. In this 
way, procedures can be controlled by setting a DEFAULT value for as little or 
as 
many variables as need be for carrying the procedure out.
LOCAL is used inside a procedure when the procedure needs thouse variables that 
are used for  other purposes outside the procedure. For example, if your 
program 
reads

10 LET a=1
20 PRINT a
30 DO_SOMETHING_PROCEDURE
40 LET a=a+1: GOTO 20

and the procedure named DO_SOMETHING_PROCEDURE used the variable a for another 
purpose, you would need to insert a LOCAL into the procedure eg. DEF PROC 
DO_SOMETHING_PROCEDURE: LOCAL a: LET a=4: LET b=a*2: END  PROC. This is 
actually 
an  extremely useless procedure, but  it is just used as an example. Because it 
contains a LOCAL, in this case LOCAL a, it uses the LOCAL variable for whatever 
it needs to, and then returns it to ist original state when it leaves the 
procedure. This can be shown by removing the LOCAL, and then RUNning the 
program.

Reply via email to