usage of def fn in basic

Post Reply
Crayon21
Posts: 141
Joined: Sun Nov 04, 2018 2:33 am

usage of def fn in basic

Post by Crayon21 » Tue Nov 26, 2019 12:25 am

can it be used for graphics?
zx81: great yet flawed
Zx spectrum: masterpiece that keeps on giving

(wish it weren't so expensive) :o

User avatar
XavSnap
Posts: 807
Joined: Sat May 10, 2008 4:23 pm

Re: usage of def fn in basic

Post by XavSnap » Tue Nov 26, 2019 9:49 am

Hi Crayon21,
Yes, but only with a numérique defined value…

10 DEF FN X=INT(a/2)
20 DEF FN Y=INT(b/2)

10 LET x=0: LET y=0: LET a=10
20 DEF FN p(x,y)=a+x
30 DEF FN q()=a+x*y
40 PRINT FN p(2,3),FN q()
RTFM > http://www.worldofspectrum.org/ZXBasicM ... chap9.html

Shaun_B
Posts: 469
Joined: Wed Apr 22, 2009 10:22 am

Re: usage of def fn in basic

Post by Shaun_B » Wed Jan 08, 2020 4:06 pm

Crayon21 wrote:
Tue Nov 26, 2019 12:25 am
can it be used for graphics?
In what way? DEF FN can be used for any calculations, so yes. You may also be able to use the USR command with it as well to call let's say certain ROM or MC routines directly.

Regards,

Shaun.

Post Reply