[Coco] DEFFN in Extended BASIC

Allen Huffman alsplace at pobox.com
Sun Jan 4 01:10:43 EST 2015


I disagree. That example's formula is 1024+Y*32+X

P=FNP(X Y)

...returns P correctly in screen memory after 1024 on the right location.

In line 90, it never uses X or Y to POKE. It uses P.

-
Allen Huffman - PO Box 22031 - Clive IA 50325 - 515-999-0227 (vmail/TXT only)
http://www.subethasoftware.com - https://www.facebook.com/subethasoftware
Sent from my iPad.

P.S. Since 4/15/2014, I have earned over $600 in Amazon gift cards! Sign up using my link and I get credit:
http://swagbucks.com/refer/allenhuffman


> On Jan 3, 2015, at 11:55 PM, William Astle <lost at l-w.ca> wrote:
> 
> This one is working because you're using X and Y as your counters so Y is getting set independently of the FN call. Try using, say, G and Q in the DEFFN statement and see what happens. You'll see that if your loop counters are not the same as your parameter variable names, you'll get a single + in the top left on the second loop.
> 
> For added fun related to your other queries:
> 
> Try this:
> 
> A=1 2 3
> PRINT A
> 
> That will print out 123. That means there is no possible way to pass multiple numeric constants using a space as the separator. Spaces are permitted inside numbers.
> 
> Try this too:
> 
> X = 5
> Y = 10
> X Y = 42
> PRINT X Y
> 
> Any guesses what is happening there? In actual fact, what happens is the "X Y = 42" line assigns 42 to a variable called "XY". This happens because the parser uses the same space-skipping next character routine when parsing variable names as it does when parsing numbers and most other things.
> 
> So, when you do the following:
> 
> DEF FNX(A B) = A + B
> 
> You are actually defining a function with a parameter called AB which is not referenced anywhere. Instead, the external variables A and B are referenced.
> 
> In other words, it wasn't doing anything like what you thought it was doing.
> 
> On 15-01-03 10:26 PM, Allen Huffman wrote:
>>> On Jan 3, 2015, at 8:43 PM, Arthur Flexser <flexser at fiu.edu> wrote:
>>> 
>>> DEF FN can take only a single argument, contrary to what it says in some
>>> Tandy documentation.
>> 
>> Test program - does the same thing with and without DEFFN, and shows the time of each:
>> 
>> 10 T1=TIMER
>> 20 FOR X=0 TO 31:FOR Y=0 TO 15
>> 30 P=1024+Y*32+X:POKE P,42
>> 40 NEXT:NEXT
>> 50 T1=TIMER-T1
>> 
>> 60 DEF FNP(X Y)=1024+Y*32+X
>> 70 T2=TIMER
>> 80 FOR X=0 TO 31:FOR Y=0 TO 15
>> 90 P=FNP(X Y):POKE P,43
>> 100 NEXT:NEXT
>> 110 T2=TIMER-T2
>> 
>> 120 PRINT T1,T2
>> 
>> The 32 column screen will be covered with inverted asterisks, then inverted plus signs.
>> 
>>        — Allen
>> 
>> 
> 
> 
> -- 
> Coco mailing list
> Coco at maltedmedia.com
> https://pairlist5.pair.net/mailman/listinfo/coco


More information about the Coco mailing list