usage of def fn in basic
usage of def fn in basic
can it be used for graphics?
In Heck, there are two options for perpetual torment:
Eat the Puckerberry and suffer for eternity:
drink nothing but a cocktail of The Last Dab and Mexican Cake blended and served with
habanero slices
Eat the Puckerberry and suffer for eternity:
drink nothing but a cocktail of The Last Dab and Mexican Cake blended and served with
habanero slices
Re: usage of def fn in basic
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)
…
Yes, but only with a numérique defined value…
10 DEF FN X=INT(a/2)
20 DEF FN Y=INT(b/2)
…
RTFM > http://www.worldofspectrum.org/ZXBasicM ... chap9.html10 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()
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
Re: usage of def fn in basic
there is even an interesting trick to even use DEF FN recursively, IIRC using VAL cleverly to enable the recursion only up to desired result.
Re: usage of def fn in basic
example please
In Heck, there are two options for perpetual torment:
Eat the Puckerberry and suffer for eternity:
drink nothing but a cocktail of The Last Dab and Mexican Cake blended and served with
habanero slices
Eat the Puckerberry and suffer for eternity:
drink nothing but a cocktail of The Last Dab and Mexican Cake blended and served with
habanero slices
- 1024MAK
- Posts: 5332
- Joined: Mon Sep 26, 2011 10:56 am
- Location: Looking forward to summer in Somerset, UK...
Re: usage of def fn in basic
The more complex uses of DEF FN (such as using DEF FN recursively, or using it in calling machine code) can get confusing rather quickly.
I suggest you get used to using it for less complex uses first.
Back to your original question, you could work out the calculation needed for working out the relationship between the BASIC graphical position (as used with PLOT) and the actual address of the relevant memory byte used. Then use DEF FN so that the calculation is only needed once in your program listing.
Or use DEF FN to calculate the relationship between PLOT coordinates and the PRINT AT position.
Mark
I suggest you get used to using it for less complex uses first.
Back to your original question, you could work out the calculation needed for working out the relationship between the BASIC graphical position (as used with PLOT) and the actual address of the relevant memory byte used. Then use DEF FN so that the calculation is only needed once in your program listing.
Or use DEF FN to calculate the relationship between PLOT coordinates and the PRINT AT position.
Mark
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor Amp
Standby alert
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb
Autumn is here. Bye bye summer 2024...
ZX81 Chip Pin-outs
ZX81 Video Transistor Amp
Standby alert
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb
Autumn is here. Bye bye summer 2024...