Some clarification please ...

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

Some clarification please ...

Postby vodkasoda » Wed Oct 22, 2014 1:02 pm

Hi all, I'm back at this big GFA game again after ages of not looking at GFA Basic. I want to make some of the program easier to follow & understand, so that if I am away from it for months at a time again, it won't be quite so difficult to get back into !!!

So, a straightforward question ... I hope ...

I have a line to get the number of the League that the user wants to process, "Input "Input league wanted: ",League" ,,, this makes League a numeric that is used throughout the program.

I have the lines below, to call a Procedure ... followed by the Procedure & a Procedure called from within the first one ...

Code: Select all

  For L=1 To Leagues <<< Please note this NOT the variable League that I am dealing with
    @Load_cup_squads(L) <<< Procedure below
  Next L


Code: Select all

Procedure Load_cup_squads(Lge)
  Local F,Loop,Squad
  '
  Lea$=Path$+"\"+Left$(League$(Lge),8)+"\LEAGUE.DAT"
  Open "i",#2,Lea$
  Print "Just opened ";Lea$
  '
  For F=1 To Teams%
    Let Loop=0
    If Cup_flag(Lge,F)=1
      @Find_loop(Lge,F) <<< Procedure below
      Seek #2,((F-1)*Record_length%)+2
      @Load_team(Loop)
    Endif
  Next F
  Close #2
Return


Code: Select all

Procedure Find_loop(League,Team) <<< This is where I just need clarification
  Local F,Halted!
  Halted!=False
  For F=1 To Game(Set)
    If Hlge(F)=League And H_team(Set,F)=Team
      Let Loop=(F*2)-1
      Halted!=True
    Endif
    '
    If Alge(F)=League And A_team(Set,F)=Team
      Let Loop=(F*2)
      Halted!=True
    Endif
    Exit If Halted!=True
  Next F
  Print "Should be at game ";F;"-";
Return


In the Procedure Find_loop, it is passed 2 variables from Procedure Load_cup_squads, they are Lge & F, but they are picked up as League & Team.

I just need to clarify that this variable, League, is totally & completely different and separate from the original League variable that the user has input at the top of the program.

I am pretty sure that I am correct, but I need to confirm it before I go making changes.

Thanks in advance ,,,

P.S. What makes people code like this ? Why not use names that make sense :-( ?!? I have the variable League in various places, also Leagues, League$, League% ,,, it's a nightmare to decode !!!

User avatar
iceman
Captain Atari
Captain Atari
Posts: 178
Joined: Sat Mar 02, 2013 11:03 pm

Re: Some clarification please ...

Postby iceman » Thu Nov 06, 2014 7:02 am

I haven't coded in GFA for decades. However, if this were C, the League variable inside the procedure should refer to the variable passed to it in it's function arguments, not the global one. It's called scope, btw, if you have any docs for GFA you can hunt through.

One way to test this would be to cut 'n paste that procedure into a new file, declare a global then call the procedure passing different variables to it. Print the results and see if they differ.
Atarian since 1989. Atari 1040STFM, 4MB 520STe with UltraSatan and Unitor N, A dodgy 1 MBSTe that bombs out after a few minutes, and a 14MB 48MHz Falcon 030 with NetUSBee and Soundpool 8 channel DAC. Plus my new MiST!


Social Media

     

Return to “GFA BASIC”

Who is online

Users browsing this forum: No registered users and 4 guests