Page 1 of 1
reading inividual letters
Posted: Mon Aug 28, 2006 2:11 pm
by sid6.7
a data(text) file was made like this
Code: Select all
gggggggggggggggggggg
gtgegvgZgggggggggggg
gggggggggggggggggggg
gagAgbgYgggggggggggg
gggggggggggggggggggg
gBgUgLgVggDggggggggg
gggggggggggggggggggg
gggggggggggggggggggg
for example i want to read each
letter and then count it on a counter...
but for some reason using plain INPUT nor GET
with TYPE/END TYPE doesnt read anything
what am i forgetting to read each individual letter?..
Posted: Mon Aug 28, 2006 3:59 pm
by Skyler
input a line, then:
Code: Select all
for x = 1 to len(line$)
y$ = mid(line$, x, 1)
'add y$ to counter here
next x
I think thats how to make mid select one char. if not, reverse x and 1 in mid$().
Posted: Mon Aug 28, 2006 4:00 pm
by bungytheworm
Reading one char at time from file like that might be a hard way. (correct me if im wrong).
I would first read one line at time to StringVariable.
Then DIM Array(LEN(StringVariable))
For Counter = 1 TO LEN(VariableA)
ArrayA(Counter) = MID$(VariableA,Counter,1)
Next Counter
If line, readed from file is IE "My line what i wana read", each cell from Array() gets one character from StringVariable.
Array(1) = "M"
Array(2) = "y"
Array(3) = " "
Array(4) = "l"
.
.
.
and so on.
Hopefully i understund your question correctly. Fix if i was wrong

Posted: Mon Aug 28, 2006 4:01 pm
by bungytheworm
Ok, skyler was bit faster on this one

Posted: Mon Aug 28, 2006 4:16 pm
by sid6.7
thanks guys...i totally forgot mid$
DOH!
This might work.
Posted: Wed Aug 30, 2006 12:48 pm
by Stoves
Code: Select all
DIM f AS INTEGER
DIM letter AS STRING * 1
f = FREEFILE
OPEN file$ FOR BINARY AS #f
DO UNTIL EOF(f)
GET #f, , letter
'Count the letter
LOOP
CLOSE #f