[Coco] DEFFN in Extended BASIC

Allen Huffman alsplace at pobox.com
Sun Jan 4 01:15:45 EST 2015


> On Jan 3, 2015, at 11:33 PM, Allen Huffman <alsplace at pobox.com> wrote:
> 
> 10 DEFFNA(A B C D)=A+B+C+D
> 20 A=1:B=10:C=100:C=1000
> 30 PRINT FNA(1 10 100 1000)
> 
> …prints 1111.
> 
> Tests show it does not work with direct numbers like FNA(1 2 3 4) but works with variables.

And, I might add, it has to be the variables you used in DEFN() for it to work. It must just simply be making a note of where that formula is, and when it sees FNx( it jumps there?

I notice it produces the expected result even if you call it as FNA(0). It just uses the A and B you defined earlier, and jumps to whatever code. It's a function GOSUB. Cool.

I guess it's time to look at Unravelled and see how it's doing this since there is an understanding that it doesn't work when clearly it does.

10 DEFFNA(A B)=A+B
20 A=10:B=1:PRINTFNA(0)
RUN
11

Slower, but could save memory.

		-- Allen


More information about the Coco mailing list