How does this code work ?!?

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

How does this code work ?!?

Postby vodkasoda » Fri Apr 26, 2013 1:39 pm

I don't understand why/how this code works, how can the IF statement not have a condition on it ?!?

Code: Select all

If Injured%(Team%,Plr%)
  @Control.(Cond$)
  @Pr.("  [*Still out for "+Str$(Injured%(Team%,Plr%))+" games*]")
Endif


The statement will only print out if the value of Injured%(Team%,Plr%) is > 0, so is there an implied "not zero" on a statement like this ?!?

User avatar
shoggoth
Nature
Nature
Posts: 853
Joined: Tue Aug 01, 2006 9:21 am
Location: Halmstad, Sweden
Contact:

Re: How does this code work ?!?

Postby shoggoth » Fri Apr 26, 2013 3:33 pm

It tests for a non-zero value.
Ain't no space like PeP-space.

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

Re: How does this code work ?!?

Postby vodkasoda » Fri Apr 26, 2013 3:58 pm

shoggoth wrote:It tests for a non-zero value.


Thanks you, I guessed that's what it must be, but it just looks so odd !!!

Does it work the same for a non-numeric variable, so something like IF A$ would trigger if A$ wasn't empty ?

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

Re: How does this code work ?!?

Postby lp » Fri Apr 26, 2013 7:44 pm

I assume you didn't try it? Reason I say that is the editor won't accept "IF a$". :wink:

You can probably do this though:

Code: Select all

IF LEN(A$)
  ' blah
ENDIF

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

Re: How does this code work ?!?

Postby simonsunnyboy » Fri Apr 26, 2013 8:03 pm

Or the more understandable version:

Code: Select all

IF a$<>""
  ' do something
ENDIF
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: How does this code work ?!?

Postby vodkasoda » Wed May 08, 2013 11:45 am

lp wrote:I assume you didn't try it? Reason I say that is the editor won't accept "IF a$". :wink:

You can probably do this though:

Code: Select all

IF LEN(A$)
  ' blah
ENDIF


No, lp, I didn't try it, it was just a thought that went through my head when getting the previous reply ...

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

Re: How does this code work ?!?

Postby vodkasoda » Wed May 08, 2013 11:46 am

simonsunnyboy wrote:Or the more understandable version:

Code: Select all

IF a$<>""
  ' do something
ENDIF


Which makes perfect sense and is totally readable & understandable :)


Social Media

     

Return to “GFA BASIC”

Who is online

Users browsing this forum: No registered users and 1 guest