Printing array problem

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
rexykik
Newbie
Posts: 2
Joined: Mon Apr 07, 2008 8:16 pm

Printing array problem

Post by rexykik »

I have the following program, and when i run it, it prints the lines from the array on separate lines instead of in the same print field. How can i get them to print within the same row of my column?

bbscores.txt is outputted in my next post.

'Program: BBtotals
'Programmer: Karl Schuttler
'Date: April 4, 2008
DECLARE SUB B000InputData ()
DECLARE SUB B010PlayerTotals ()
DECLARE SUB B020GameTotals ()
CLS
CONST intPlayers = 10
CONST intGames = 3
DIM SHARED sngScores(intPlayers, intGames) AS SINGLE
CALL B000InputData
CALL B010PlayerTotals
CALL B020GameTotals
END

SUB B000InputData
DIM intPlayerCount AS INTEGER
DIM intGameCount AS INTEGER
OPEN "bbscores.txt" FOR INPUT AS #1
intPlayerCount = 1
DO WHILE intPlayerCount <= intPlayers
intGameCount = 1
DO WHILE intGameCount <= intGames
INPUT #1, sngScores(intPlayerCount, intGameCount)
intGameCount = intGameCount + 1
LOOP
intPlayerCount = intPlayerCount + 1
LOOP
CLOSE #1
END SUB

SUB B010PlayerTotals
DIM intPlayerCount AS INTEGER
DIM intGameCount AS INTEGER
DIM sngPlayerTotal AS SINGLE
PRINT , "Game", "Game", "Game", "Player"
PRINT , "1", "2", "3", "Ave"
PRINT
intPlayerCount = 1
DO WHILE intPlayerCount <= intPlayers
PRINT "player"; intPlayerCount,
sngPlayerTotal = 0
intGameCount = 1
DO WHILE intGameCount <= intGames
PRINT sngScores(intPlayerCount, intGameCount)
sngPlayerTotal = sngPlayerTotal + sngScores(intPlayerCount, intGameCount)
intGameCount = intGameCount + 1
LOOP
sngPlayerTotal = sngPlayerTotal / intGames
PRINT sngPlayerTotal;
intPlayerCount = intPlayerCount + 1
LOOP
END SUB

SUB B020GameTotals
DIM intGameCount AS INTEGER
DIM intPlayerCount AS INTEGER
DIM sngGameTotal AS SINGLE
PRINT
PRINT "Game Total",
intGameCount = 1
DO WHILE intGameCount <= intGames
sngGameTotal = 0
intPlayerCount = 1
DO WHILE intPlayerCount <= intPlayers
sngGameTotal = sngGameTotal + sngScores(intPlayerCount, intGameCount)
intPlayerCount = intPlayerCount + 1
LOOP
PRINT USING " ###"; sngGameTotal;
intGameCount = intGameCount + 1
LOOP
END SUB
rexykik
Newbie
Posts: 2
Joined: Mon Apr 07, 2008 8:16 pm

Post by rexykik »

12
15
18
10
11
12
4
6
7
0
9
8
0
0
0
20
22
24
0
1
2
5
0
1
0
9
13
4
0
5
Mac
Veteran
Posts: 151
Joined: Mon Aug 06, 2007 2:00 pm

Re: Printing array problem

Post by Mac »

rexykik wrote:How can i get them to print within the same row of my column?
Put a semi-colon at the end of
PRINT sngScores(intPlayerCount, intGameCount)

Like this
PRINT sngScores(intPlayerCount, intGameCount);

Right?

Mac
Mac
Veteran
Posts: 151
Joined: Mon Aug 06, 2007 2:00 pm

You there?

Post by Mac »

Any chance you will thank me or ask for further info?

Let's not be an Ephemeralus

Mac
Post Reply