![]() | Sample 4 Spirals, $, XEQ, F-keys |
F2() ! programmed call to F2.
F3()
F4()
F6()
F8()
END
FUNCTION F2() ! The $ variable populates an array
SYSTEM(BackGround=995, FontSize=18)
DLG(Left=1/4, Wid=1/2, Nr=1, TItle='To step into a FUNCTION: Shift+ENTER', Edit='#explain$', But='OK')
$VEC(1000) = 0 ! to define the length of $VEC
$VEC($) = $ ^ 2 ! to check: F1 or a right mouse button click on the item of interest
DLG(Left=3/4, Wid=1/4, Owner=1, Array=$VEC, SCRoL=20, TItle='nr,$VEC($) = $ ^ 2. Click here. Try menu.')
DLG(Kill=1)
F3()
END
FUNCTION F3() ! calculate Factorials
DO
DLG(NumEdit=$max,SYMbol, NE=factorial,SYM,BG=0, E='#F3notes', B="Calculate factorial($max)", XEQ="factorial = FACTOR()", B='Exit')
IF($txtRC == 'Exit') EXIT
ENDDO
F4()
END
FUNCTION FACTOR()
. $max = $max + 1 ! $ runs from 1 to $max
factorial = 1 ! initial value to get FACTORIAL(arg)
factorial = factorial * $ ! = 1 x 2 x 3 x ... x arg
RETURN factorial
END
FUNCTION F4() ! Random values, Graph, and display of $VEC
$max = 100
$VEC(100) = 0 ! to define the length of $VEC
$VEC($) = RAN(50, 20)
DLG(R=2,C=2,AXis=2, TI='Random numbers $VEC as a function of the "number" $', Y=0, TI='30 + RAN(40)')
LINE(AXis=2, X=$, Y=$VEC($), Symbol='●', Draw=-900)
DLG(Wid=1/3, Array=$VEC, TIt=',RAN(50) +- 20')
F5()
END
FUNCTION F5() ! Fibonacci numbers with graph and table
$max = 50
Fibonacci($max,1) = 0
Fibonacci($max,2) = 0
Fibonacci(1,1) = 1
Fibonacci(2,1) = 1
Fibonacci($,1) = Fibonacci($-2,1) + Fibonacci($-1,1)
Fibonacci($,2) = Fibonacci($-1,1) / Fibonacci($-2,1)
DLG(TItle='Fibonacci Numbers', R=2,C=2,AXis=4, X=0,MAX=$max,TI='index', Y=0,FMT='LOG', MAX=1E9,TI='Fibonacci number')
LINE(AX=4, X=$, Y=Fibonacci($), S='●', Draw=9)
DLG(W=1/2, Hei=1/2, Array=Fibonacci, TIt=',Fibonacci: x(n)=x(n-1)+x(n-2),Golden Ratio: x(n)=x(n-1)/x(n-2) ')
F6()
END
FUNCTION F6() ! Archimedes spiral
$max = 300
DLG(TI='Archimedes Spiral', R=2,C=2,AXis=1, X=0,MIN=-1,MAX=1,TI='$/$max*COS($/10)', Y=0,MIN=-1,MAX=1,TI='$/$max*SIN($/10)')
LINE(AX=1, X=COS($/10)*$/$max, Y=SIN($/10)*$/$max, W=3, Draw=900)
F8()
END
FUNCTION F8() ! Logarithmic spiral
$max = 999
a = 5
DLG(TI='Logarithmic Spiral', R=2,C=2,AXis=3, X=0,MIN=-a,MAX=a,TI='LOG($/a)*COS($/10)', Y=0,MIN=-a,MAX=a,TI='LOG($/a)*SIN($/10)')
LINE(AX=3, X=COS($/10)*LOG($), Y=SIN($/10)*LOG($), W=3, Draw=99*$/$max)
DLG(TItle=' ',B='Quit', BackGround=900)

IF($txtRC == 'Quit') SYSTEM(QUIT=1)
END