10-27-2004, 07:43 AM
Here's my code so far. I'm making a high score program for my girlfriend for InkLink (She's obsessed). I have run into this problem before in other programs and I can't beat it.
I have input all the high scores that will be saved to a .txt file, but then I need to organize those top scores in descending order. That's where the problem starts. How can I take 10 or so string variables and order them in descending order without making 500 if statements? I could go on forever if D$(1) > D$(2) and D$(1) > D$(3), etc. But I don't even know if that could work, and there has to be an easier way. I tried to read them in using the Data command, but I still can't get them in order.
Any help is appreciated. Please use the simplest code possible. I don't know all the advanced commands.
CLS
COLOR 11
PRINT ""
PRINT " Amie's InkLink top score program. Version 1.0"
PRINT ""
PRINT ""
PRINT ""
PRINT " To ADD a top score press the 'a' key at the prompt."
PRINT ""
PRINT " To see your TOP scores press the 't' key at the prompt."
PRINT ""
INPUT B$
SELECT CASE B$
CASE a
PRINT ""
PRINT " Great job Amie! Type your high score at the prompt."
PRINT ""
INPUT C$
PRINT ""
PRINT " Your new high score is"; C$
PRINT ""
OPEN "InkLinks.txt" FOR INPUT AS #1
DIM D$(1 TO 10)
FOR E = 1 TO 10
INPUT #1, D$(E)
NEXT
'Here's where I need to sort which string is the highest. I'm lost as to
'how to do it.
'Here's how I did it:
FOR E = 1 TO 10
FOR F = 1 TO 10
IF D$(E) > D$(F) THEN
SWAP D$(E), D$(F)
ELSE
END IF
NEXT
NEXT
FOR E = 1 TO 10
PRINT D$(E)
NEXT
CASE t
end
Below is the contents of the InkLinks.txt file:
=============================
100
500
600
200
700
900
300
150
000
000
I have input all the high scores that will be saved to a .txt file, but then I need to organize those top scores in descending order. That's where the problem starts. How can I take 10 or so string variables and order them in descending order without making 500 if statements? I could go on forever if D$(1) > D$(2) and D$(1) > D$(3), etc. But I don't even know if that could work, and there has to be an easier way. I tried to read them in using the Data command, but I still can't get them in order.
Any help is appreciated. Please use the simplest code possible. I don't know all the advanced commands.
CLS
COLOR 11
PRINT ""
PRINT " Amie's InkLink top score program. Version 1.0"
PRINT ""
PRINT ""
PRINT ""
PRINT " To ADD a top score press the 'a' key at the prompt."
PRINT ""
PRINT " To see your TOP scores press the 't' key at the prompt."
PRINT ""
INPUT B$
SELECT CASE B$
CASE a
PRINT ""
PRINT " Great job Amie! Type your high score at the prompt."
PRINT ""
INPUT C$
PRINT ""
PRINT " Your new high score is"; C$
PRINT ""
OPEN "InkLinks.txt" FOR INPUT AS #1
DIM D$(1 TO 10)
FOR E = 1 TO 10
INPUT #1, D$(E)
NEXT
'Here's where I need to sort which string is the highest. I'm lost as to
'how to do it.
'Here's how I did it:
FOR E = 1 TO 10
FOR F = 1 TO 10
IF D$(E) > D$(F) THEN
SWAP D$(E), D$(F)
ELSE
END IF
NEXT
NEXT
FOR E = 1 TO 10
PRINT D$(E)
NEXT
CASE t
end
Below is the contents of the InkLinks.txt file:
=============================
100
500
600
200
700
900
300
150
000
000