Page 1 of 1

Reading a part of text file.

Posted: Sat Nov 13, 2004 4:00 am
by Guest
I have a txt file and there is 50 lines and in each line has 50 ascii marks.

How i can read ascii marks on area that is lines 20-30 and rows 10-15?

Hope you get what i mean.

Posted: Sat Nov 13, 2004 8:50 am
by {Nathan}
Hmm... you can't with QB but I do know how you can. If you know maps with rpgs darkdread style then this will be very easy for you. Follow the steps and there you go.

1. In between every character, put a comma (I don't know any faster way, sorry)

2. DIMension the array (1 TO 50, 1 TO 50)

3. Load the file into the array the same way you would a map.

Code: Select all

FOR y = 1 to 50
FOR x = 1 to 50
INPUT Array(X, Y)
NEXT
NEXT
Now your file is in the computers ram.

4. Read it the same way you would a map.

Code: Select all

FOR Y = 20 TO 30
FOR X = 10 TO 15
Array(X, Y) = ....
NEXT
NEXT
That will give you the charectars you want. I would reccoment putting them in a new array if you are using them more than once. Otherwise, this will do if you are doing something really simple (like printing it to a screen)

Posted: Sat Nov 13, 2004 11:00 am
by Nodtveidt
Sure you can with QB. If it's an ASCII file, all you need to know how to do is:

1. Keep track of line numbers (hint: use variables)
2. Know how to use MID$
3. Know how to use LINE INPUT
4. Knowledge of fixed-length strings might help if all the lines are of the same size, otherwise, just knowing how to work with strings is all you need

It's quite elementary, really. :D

Posted: Sat Nov 13, 2004 1:07 pm
by {Nathan}
I hate you... grrr... hey, it was early. I like to take the long ways sometimes, anyway. It's also fun to confuse noobies sometimes.

Posted: Sat Nov 13, 2004 7:29 pm
by lurah-
Nathan. i coded with basic before even you were born. Sorry if i was gone like a years...

Posted: Sat Nov 13, 2004 7:41 pm
by Nodtveidt
I have no idea what the relevance to that could possibly be. :shock:

Posted: Sat Nov 13, 2004 9:14 pm
by lurah-
Nathan1993 wrote: anyway. It's also fun to confuse noobies sometimes.
Something like that...[Edit]...grow up.[/Edit] :wink:

Posted: Sun Nov 14, 2004 8:31 am
by {Nathan}
... :cry: leave me alone! *calls 911* Hello, operater, I am being harrassed by some guy...

Hey, it is still fun to confuse people. Plus, I don't see many tutors by you. And I'am only 11, so give me a freakin brake already *runs of crying and goes start playing Grand Theft Auto: San Andreas*

:cry: Give me a break!!!

Posted: Mon Nov 15, 2004 4:52 pm
by {Nathan}
Now, I am off to go play San Andreas (I just got done crying)