Jump to content



0

Noob in basic


4 replies to this topic

#1 Champions_2002 OFFLINE  

Champions_2002

    Star Raider

  • 84 posts
  • Location:Manchester England

Posted Tue May 17, 2011 10:05 AM

I am trying to teach myself Atari Basic, i can do the basic's print to screen use read and so on, i have a problem, i want to make a league table (Football/Soccer) i have put the teams in a data line (only 4) and i have printed them on screen at the top, i want to use another data line to pick which team play the other.

Here is my code so far
1 REM SMALL FIXTURE LIST
2 GRAPHICS 0
3 DIM T$(20),F(24):PLD=0:W=0:L=0:F=0:A=0:PTS=0
4 POSITION 15,2:PRINT "PLD  W  D  L  F  A  PTS"
5 FOR B=1 TO 4
6 READ T$
7 POSITION 1,B+3:PRINT T$
8 NEXT B
9 FOR B=1 TO 4
10 POSITION 16,B+3:PRINT PLD:POSITION 20,B+3:PRINT W:POSITION 23,B+3:PRINT D:POSITION 26,B+3:PRINT L
11 POSITION 29,B+3:PRINT F:POSITION 32,B+3:PRINT A:POSITION 36,B+3:PRINT PTS
12 NEXT B
20 RESTORE 101
21 FOR B=1 TO 24
22 READ F
23 NEXT B
24 POSITION 1,10:PRINT T$(4)
100 DATA TEAM 1,TEAM 2,TEAM 3,TEAM 4
101 DATA 1,2,4,3,3,1,2,4,4,1,2,3,3,2,1,4,1,3,4,2,2,1,3,4

LINE 101 Is what team plays so the first two games are 1v2 and 4,3, what i want is basic to read line 101 and then get the right number and then pick the team that corresponds with the number and print to the bottom of the screen and so forth until all games are shown, but only show the first 6 at home and 6 away

Can somebody help me do this

#2 Rybags ONLINE  

Rybags

    Quadrunner

  • 10,313 posts
  • Location:Australia

Posted Tue May 17, 2011 11:22 AM

Probably best to keep all the team names in one string since we don't have string arrays.

So something like:

1000 DIM TEAM$(256),T$(16)
1010 TEAM$(1)=" ":TEAM$(256)=" ":TEAM$(2)=TEAM$
1020 RESTORE 1200
1030 FOR T=0 TO 15 : REM Cater for 16 Teams
1040 READ T$
1050 TEAM$(1+T*16)=T$
1060 NEXT T
1200 DATA TEAM NAME 1,TEAM NAME 2
etc.

Then you can extract each team name by using part of the string, e.g.

200 T=3:REM Team we want is the fourth one (first team is 0)
210 T$=TEAM$(1+T*16,16+T*16)

Also best in Basic to use line numbers incremented by at least 10. That way if you need to insert new code you won't be cramped for line numbers.

Edited by Rybags, Tue May 17, 2011 11:22 AM.


#3 Champions_2002 OFFLINE  

Champions_2002

    Star Raider

  • 84 posts
  • Location:Manchester England

Posted Tue May 17, 2011 3:00 PM

View PostRybags, on Tue May 17, 2011 11:22 AM, said:

Probably best to keep all the team names in one string since we don't have string arrays.

So something like:

1000 DIM TEAM$(256),T$(16)
1010 TEAM$(1)=" ":TEAM$(256)=" ":TEAM$(2)=TEAM$
1020 RESTORE 1200
1030 FOR T=0 TO 15 : REM Cater for 16 Teams
1040 READ T$
1050 TEAM$(1+T*16)=T$
1060 NEXT T
1200 DATA TEAM NAME 1,TEAM NAME 2
etc.

Then you can extract each team name by using part of the string, e.g.

200 T=3:REM Team we want is the fourth one (first team is 0)
210 T$=TEAM$(1+T*16,16+T*16)

Also best in Basic to use line numbers incremented by at least 10. That way if you need to insert new code you won't be cramped for line numbers.

Thanks Rybags

how can i print out the teams like this

Team 1 - Team 2
Team 3 - Team 4

or any other way

#4 georgemilton OFFLINE  

georgemilton

    Combat Commando

  • 3 posts

Posted Thu May 19, 2011 8:15 PM

how can i print out the teams like this

Team 1 - Team 2
Team 3 - Team 4

or any other way


Using the above code
1065 X=5:Y=7: REM assign X to first team number and Y to second team number in this case 5 and 7
1070 PRINT TEAM$(1+X*16,1+X*16+15);" - -";TEAM$(1+Y*16,1+Y*16+15)

#5 Champions_2002 OFFLINE  

Champions_2002

    Star Raider

  • 84 posts
  • Location:Manchester England

Posted Thu Jun 2, 2011 2:57 AM

View Postgeorgemilton, on Thu May 19, 2011 8:15 PM, said:

how can i print out the teams like this

Team 1 - Team 2
Team 3 - Team 4

or any other way


Using the above code
1065 X=5:Y=7: REM assign X to first team number and Y to second team number in this case 5 and 7
1070 PRINT TEAM$(1+X*16,1+X*16+15);" - -";TEAM$(1+Y*16,1+Y*16+15)

Thanks




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users