<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>
Date   : Fri, 11 Feb 2005 11:49:35 +0000
From   : Richard Gellman <splodge@...>
Subject: Re: programming tips

PROCs and FNs are powerful statements that make BBC BASIC so unique 
amongst 8-bit machines.

PROCedures and FuNctions can be thought of named GOSUBs. You DEFine a 
PROCedure somewhere in the program, along with paramters you'd like it 
to accept. That PROC can be be called at anytime without needing to know 
its line number.

FuNctions are similar, but they can return values, ex:

y=FNequation(x,a,b,c)
PRINT "if y=ax2+bx+c, then y=";y
END

DEF FNequation(x,a,b,c)
REM example statement to show FNs can be multiline
=((a*x)*(a*x))+(b*x)+c

-- Richard

Tom Drage wrote:

>10 REM Magic Number
>20 REM by Thomas Drage, modified by Darren Izzard
>30 REPEAT
>40 MODE 4
>50 PRINT TAB(8,1)"Welcome to Magic Number!"
>60 COLOUR 2:PRINT TAB(5,2)"by Thomas Drage/Darren Izzard"
>70 B%=RND(20)
>80 REPEAT
>90 COLOUR 3:INPUT'"Enter your guess:"G%
>100 IF G%=B% THEN PROCcorrect
>110 IF G%>B% THEN COLOUR 2:PRINT "Too big! Try again."
>120 IF G%<B% THEN COLOUR 2:PRINT "Too small! Try again."
>130 UNTIL G%=B% OR G%=0
>140 IF G%=0 THEN PRINT'"Goodbye!":END
>150 PRINT'"Do you want to try again? ";
>160 REPEAT
>170 A$=GET$
>180 UNTIL INSTR("YyNn",A$)<>0
>190 PRINT A$
>200 UNTIL A$="N" OR A$="n"
>210 PRINT'"Goodbye!"
>220 END
>230 DEF PROCcorrect
>240 CLS
>250 GCOL 0,1
>260 MOVE 200,300
>270 DRAW 350,250
>280 DRAW 460,575
>290 PRINT TAB(16,25)"Correct!"
>300 ENDPROC
>
>Hi, just a few things. Could you please explain this PROC idea, line 170 and
>line 180.
>
>Sorry about this, but I'm trying to learn so I'm not too good.
>
>
>
>
>
>Tom Drage
>            www.draget.net 
>
>
>  
>
   
<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>