Printing to specific columns, but indirectly ...

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

Printing to specific columns, but indirectly ...

Postby vodkasoda » Wed May 08, 2013 12:05 pm

The program I am working on uses Tabs to print data, as per the following example ...

Code: Select all

If Inj_team%(F%)=Home Or Inj_team%(F%)=Away
  If Inj_team%(F%)=Home
    myTab$=""
   Endif
  If Inj_team%(F%)=Away
    myTab$=Tab$+Tab$+Tab$+Tab$+Tab$+Tab$+Tab$+Tab$
  Endif
  myInj$= xxxxx !This is concatenated data, something like "15, Jones, was injured"
  Inc NlCount1%
  Newsletter1$(NlCount1%)=myTab$+myInj$
EndIf


Later in the program, the Newsletter1$ array is printed via a standard Print command

Code: Select all

For Ix = 1 to NlCount1%
  If Newsletter1$(Ix)<>""
    Print #79,Newsletter1$(Ix)
    Newsletter1$(Ix)=""
  Endif
Next Ix


I have numerous other lines that are printed the same way, but sometimes the Tabbing is wrong, because of the length (or lack) of some data, there may well be an extra Tab needed, or a Tab should have been omitted. Therefore I'd like to specify an exact column, but I'm not sure how to go about it, so am just putting this out there to see if anybody has experience of anything similar, or just knows the best way to do it ...

I haven't used it, but it looks like this is do-able with the "PRINT AT" command if I was doing the printing immediately, but as I am not, and it's being deferred until later (this is because I want to sort the data in the array before it gets printed) I am looking into different ways of doing it ... any ideas or suggestions would be welcomed :cheers:

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

Re: Printing to specific columns, but indirectly ...

Postby vodkasoda » Wed May 08, 2013 12:17 pm

Hmmm, I think I may be overcomplicating matters ... if I just have myTab$ defined as 30 spaces (for instance) then I can probably just concatenate it if it's needed ...

Dal
Administrator
Administrator
Posts: 4079
Joined: Tue Jan 18, 2011 12:31 am
Location: Cheltenham, UK
Contact:

Re: Printing to specific columns, but indirectly ...

Postby Dal » Wed May 08, 2013 7:50 pm

I would separate your 'game' logic from your display stuff.

Create your arrays and then have a routine which can loop through the arrays and print them in the correct place.

Here's an idea of how you might approach it. I've not tested this code, and you'll need to add some tests to ensure you don't go out of bounds with the arrays, but you should be able to at least get the idea from this example:

Code: Select all

DIM Injuries$.Home(15)           !Global placeholder for 'home' injuries
DIM Injuries$.Away(15)            !Global placeholder for 'away' injuries
Injuries.Home.ptr%            !Global pointer to next injury
Injuries.Away.ptr%             !Global pointer to next injury

PROCEDURE injuries.set(F$)
If Inj_team%(F%)=Home
  Injuries$.Home(Injuries.Home.ptr%)= xxxxx !This is concatenated data, something like "15, Jones, was injured"
  Inc Injuries.Home.ptr%
EndIf
If Inj_team%(F%)=Away
  Injuries$.Away(Injuries.Away.ptr%)= xxxxx !This is concatenated data, something like "15, Jones, was injured"
  Inc Injuries.Away.ptr%
EndIf
RETURN

PROCEDURE Newsletter.Show
For Newsletter.Injuries.Home.ptr%=0 to Injuries.Home.ptr%
  PRINT AT(0,Newsletter.Injuries.Home.ptr%+5);Injuries.Home$(Newsletter.Injuries.Home.ptr%)
Next Newsletter.Injuries.Home.ptr
For Newsletter.Injuries.Away.ptr%=0 to Injuries.Away.ptr%
  PRINT AT(30,Newsletter.Injuries.Away.ptr%+5);Injuries.Away$(Newsletter.Injuries.Away.ptr%)
Next Newsletter.Injuries.Away.ptr
RETURN


The display routine starts 5 lines down so there is enough space for any header information.
TT030: 4MB/16MB + Crazy Dots, Mega"SST" 12, MegaSTE, STE: Desktopper case, IDE interface, UltraSatan (8GB + 512Mb) + HXC floppy emulator. Plus some STE's/STFM's

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

Re: Printing to specific columns, but indirectly ...

Postby vodkasoda » Thu May 09, 2013 8:01 am

Thank you, I'll fiddle around with my code and see how it goes, much appreciated ...


Social Media

     

Return to “GFA BASIC”

Who is online

Users browsing this forum: No registered users and 1 guest