Qbasicnews.com

Full Version: stuck need help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
ok here is the question.. im working on trying to figure out a sort routine were the code will sort my txt file of names by last name.

I try the the line
Print Mid$(presname$(i)) but get errors.. can you tell me why it does that. I know it is somewhere with that line but not sure why..

Quote:CLS
PRINT TAB(60); "*"
PRINT TAB(60); "*"

DIM presname$(0 TO 42)

OPEN "f:/pres.txt" FOR INPUT AS #1
DIM index

INPUT #1, presname$(index)
DO WHILE NOT EOF(1)
index = index + 1
INPUT #1, presname$(index)
LOOP



FOR i = 0 TO 42
PRINT presname$(i)
NEXT i



OPEN "f:/output.txt" FOR OUTPUT AS #2

FOR i = 0 TO 42
PRINT #2, presname$(i)
NEXT i
MID$ takes three arguments, not one...

MID$(string_to_get_part_of$, starting_place%, length_to_take%) (I think, the last two might be the other way around).

You'll have to do some basic math to work out the last two parameters.
cool. that could be why it wasnt working...lol ill try it. thanks.
hmm obviously i cant get it. now could i use a bubble sort and somehow get it to read the last name first, then the first and middle.... i kind of have a idea how it works but
anyone up for all nighter im stuck..lol i suck at this stuff.. lol
Well, we'll need more clues than that to help you out. Posting that "i've got a problem with a bubble sort" and then not posting the code is pretty pointless Wink

Post your code, and where you're stuck, and then anyone here can help you Smile