DEFFN command

GFA BASIC-related articles in here please

Moderators: exxos, simonsunnyboy, Mug UK, Zorro 2, Moderator Team

vodkasoda
Atari maniac
Atari maniac
Posts: 94
Joined: Wed Jul 07, 2010 3:55 pm

DEFFN command

Postby vodkasoda » Thu Nov 05, 2015 12:15 pm

I have a command which says ...

Code: Select all

Pd%(Team)=@Get_var4(Chan)


... where Team is a number between 1 & 48 and Chan = 5

It seems to return 0, 1 and rarely -1

This is the code it is calling, from what I understand ...

Code: Select all

Deffn Get_var4(Chan)=Cvl(Chr$(Inp(#Chan))+Chr$(Inp(#Chan))+Chr$(Inp(#Chan))+Chr$(Inp(#Chan)))


... can anybody please explain, in plain English, what this doing and how it gets -1 occasionally ?!?

Thanks in advance :cheers:

vodkasoda
Atari maniac
Atari maniac
Posts: 94
Joined: Wed Jul 07, 2010 3:55 pm

Re: DEFFN command

Postby vodkasoda » Thu Nov 05, 2015 12:18 pm

Apologies that this has posted twice, I got told there was a "Server error 500" both times I tried to post it !!! Good job I stopped at 2 & saved my draft !!!

User avatar
lp
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2257
Joined: Wed Nov 12, 2003 11:09 pm
Location: GFA Headquarters
Contact:

Re: DEFFN command

Postby lp » Thu Nov 05, 2015 2:21 pm

It looks like it reads 4 bytes from a device (file?), concatenates them together as a string, and then finally converts that to a long value. This would perhaps do the same, but shorter:

Code: Select all

pd%(team)=CVL(INPUT$(4,#chan))
' or
pd%(team)=INP%(#chan)

I didn't test these, just going by my interpretation of your code and possibly you could eliminate the DEFFN all together. Please note that my answers always assume GFA v3.6. ;)

vodkasoda
Atari maniac
Atari maniac
Posts: 94
Joined: Wed Jul 07, 2010 3:55 pm

Re: DEFFN command

Postby vodkasoda » Thu Nov 05, 2015 2:33 pm

Thank you, if it's getting data from reading a file then that could explain why it causes a crash if I try to print it after it's run, it's probably taking data from somewhere it shouldn't, there is loads of data in this program, it's a nightmare trying to find what is what !!!

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 4867
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: DEFFN command

Postby simonsunnyboy » Thu Nov 05, 2015 5:04 pm

IMHO this is an unreadable mess.
I personally would convert it into a commented multiline FUNCTION, assuming you have GFABASIC 3 or later.
Simon Sunnyboy/Paradize - http://paradize.atari.org/ - STOT: http://www.npoi.de/stot/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

Jabber: simonsunnyboy@atari-jabber.org

vodkasoda
Atari maniac
Atari maniac
Posts: 94
Joined: Wed Jul 07, 2010 3:55 pm

Re: DEFFN command

Postby vodkasoda » Mon Nov 16, 2015 10:27 pm

simonsunnyboy wrote:IMHO this is an unreadable mess.
I personally would convert it into a commented multiline FUNCTION, assuming you have GFABASIC 3 or later.


Huge areas of the program are "an unreadable mess" unfortunately, but I don't have the time or the knowledge to rewrite it all :-(

Thanks for replying though 8)


Social Media

     

Return to “GFA BASIC”

Who is online

Users browsing this forum: No registered users and 1 guest