Welcome to the forums Animated C4.
So you want to present this data in a clearer way?
I would display it in a table, but before I show you how to do that I'm going to have a look at your code and see if there are any improvements I can suggest.
It's a good idea to split your programs into three parts: The first part is where everything is initialised - this is where I would dimension all your arrays. The second part is where the real work is done; this section is often in the form of a loop that the program continues to run until the user exits the loop.
The final part is where everything is tidied up and deleted before ending the program. Since DB does a lot of cleaning up for you, you often wont need to have this clean-up section. You have used the END command which is good practice, when you start to use subroutines and functions you'll see why it is so important.
The basic process of your program as I understand is this:
(pseudo code flowcharty thing)
00 Get input
01 Check input against END condition
02 If END condition is TRUE GOTO 06
03 Store input in character$ array
04 Generate random X and Z coordinates and store in arrays
05 If character number is less than max, increment and GOTO 00
06 Display Characters
07 END
From this diagram we can see two distinct parts of the main program. The first is the loop that gathers and stores the input and random values. The second part displays the data.
So here is what I have so far:
rem === SETUP ===
max = 6
dim character$(max)
dim characterx(max)
dim characterz(max)
rem === MAIN ===
rem input
for i = 0 to max
cls
print "type in 'end' when you are done."
input "give me a character name ", temp$
if temp$ = "end" then exit
character$(i)= temp$
characterx(i)= rnd(10)+1
characterz(i)= rnd(10)+1
next i
rem display (nothing yet)
end
I put that "max" variable in so you can easily change how many characters you want the limit to be. See how now your end condition is in a loop it has a real effect. I've altered it so instead of ending the program it exits the loop and proceeds to the display section.
Now we've got everything done except the display. To arrange the data in a simple table we'd do something like this
cls
set cursor 0,0 : print "NAME"
set cursor 100,0 : print "X POS"
set cursor 180,0 : print "Z POS"
for i = 0 to max
set cursor 0,(i+1)*18 : print character$(i)
set cursor 100,(i+1)*18 : print characterx(i)
set cursor 180,(i+1)*18 : print characterz(i)
next i
The column positions are constant (0,100 and 180) for the different types of data, the interesting part is how the rows are positioned. We use the index number of the array to distinguish the characters from each other. 18 is the space (in pixels) from the top of one row to the top of the next - try changing this and see the spacings change - multiplying that by the index gives a nice ordered list.
Hope that helps.
PS I've made a fancier version that adjusts the width of the name column based on how long the names are.
rem === SETUP ===
max = 6
dim character$(max)
dim characterx(max)
dim characterz(max)
rem start column width as title width
columnwidth = text width("NAME")
rem === MAIN ===
rem input
for i = 0 to max
cls
print "type in 'end' when you are done."
input "give me a character name. >", temp$
if temp$ = "end" then exit
character$(i)= temp$
characterx(i)= rnd(10)+1
characterz(i)= rnd(10)+1
rem adjust name column width?
if text width(temp$) > columnwidth then columnwidth = text width(temp$)
next i
rem display
xcolumn = 10+columnwidth
zcolumn = 60+columnwidth
cls
set cursor 0,0 : print "NAME"
set cursor xcolumn,0 : print "X POS"
set cursor zcolumn,0 : print "Z POS"
for i = 0 to max
set cursor 0,(i+1)*18 : print character$(i)
set cursor xcolumn,(i+1)*18 : print characterx(i)
set cursor zcolumn,(i+1)*18 : print characterz(i)
next i
end
If you have any questions just ask.
[edit]
Oops I just did someone's homework for them
I'll leave it here as I've spent about an hour on this thread but please don't just copy my code. I wrote this for you to learn from
"With games, we create these elaborate worlds in our minds, and the computer is there to do the bookkeeping." - Will Wright