Quote:dont you think what youve done is a bit too complicated ?
What I've "done" is try to *help* you!!
Seriously, I wrote the program in about 15 minutes and posted it"untested"...then decided to test it...there was only 1 bug...in the viewIt subroutine, I mistakenly used the variable index as the array subscript, instead of i. I then decided to clean up the interface a bit and spent 15 min more...trying to *help* you.
The sample code is easy to follow and allows you to learn the basics of:
TYPE structures
Arrays
block IF/THEN
Select case
and demonstrates the usefulness of modularity (although you would really use SUBs instead of GOSUBs.
Inkey$
simple menus.
nested loops
These are all very important programming concepts.
If you are *interested*, to be useful, you would want to make this program output the array to a file...and read the file back into the array when the program is run...so that you would never have to enter the same text twice. This feature would be simple to implement whenever you are ready for file I/O.
Allowing Humans to avoid performing the same task many times is the *whole point* of computers. If you wrote the program using a unique variable name for each album, and then use conditional IF/THEN statements for each one...you'd have a lot more typing to do in the code, and each time you wanted to add another album, you'd have to modify the code...which is not my idea of a well-designed or well-written program :roll:
Using an array of TYPEs may be too complicated if you don't yet understand arrays.
See the following for a simple program that uses arrays:
Code:
CLS
DEFINT M 'forces min & max to integers...not really needed
min = 1
max = 5
DIM myArray(min TO max) AS SINGLE 'creates 5 variables...all at once
PRINT "Please enter "; max; " numbers"
FOR index = min TO max STEP 1
PRINT "Enter #"; index;
INPUT myArray(index)
NEXT index
PRINT : PRINT
PRINT "Great...I have my numbers. Want to see them?"
SLEEP
PRINT : PRINT
PRINT "Here they are"
GOSUB showArray
PRINT "want to see them in reverse order?"
SLEEP
FOR i = max TO min STEP -1
PRINT myArray(i);
NEXT i
PRINT : PRINT
PRINT "Now...I'll print the double of each value"
SLEEP
FOR i = min TO max
PRINT myArray(i) * 2;
NEXT i
PRINT : PRINT
PRINT "But...The original values remain"
SLEEP
GOSUB showArray
PRINT "Now, I'll double each value"
SLEEP
FOR i = min TO max
myArray(i) = myArray(i) * 2
NEXT i
GOSUB showArray
PRINT "Now...let's order these values"
SLEEP
DO
noswap = 1
FOR i = min TO max - 1
IF myArray(i) > myArray(i + 1) THEN
SWAP myArray(i), myArray(i + 1)
noswap = 0
END IF
NEXT i
LOOP UNTIL noswap = 1
PRINT "ta da...They are in ascending order"
GOSUB showArray
PRINT : PRINT
PRINT "Over and Out!!"
END
showArray:
FOR i = min TO max
PRINT myArray(i);
NEXT i
PRINT : PRINT
RETURN