|
-
Jan 24th, 2000, 05:02 PM
#1
Thread Starter
Junior Member
i wish to open a file in binary mode (so i can read each character at a time, including EOF, CR, LF etc) using a Do Until EOF loop.
i think i am supposed to use GET but i am not sure how to read a single character, i can read the whole file at once, but this is not what i want to do. thanks in advance
-
Jan 24th, 2000, 06:22 PM
#2
So Unbanned
Reading the whole file then using a string function would be faster i.e.
Code:
'LoadFile here
TheFileContents = 'What's in the file
For x = 1 to len(TheFileContent)
TheChr = mid$(TheFileContent,x,1)
'Things you want to do with this character
Next x
Hope I helped,
------------------
DiGiTaIErRoR
VB, QBasic, Iptscrae, HTML
Quote: There are no stupid questions, just stupid people.
-
Jan 24th, 2000, 06:57 PM
#3
Thread Starter
Junior Member
sorry, i didnt explain why i cant do that, i have to do it one byte at a time.. because i will be reading large files (ie > 50 MB) and these will not all fit into one string, they may fit in a variant but i am not willing to use all the ram that way 
-
Jan 25th, 2000, 05:12 AM
#4
You could declare a user defined type of one string character
Code:
Type OneChar
OneByte As String * 1
End Type
Then you could open the file for random and access it one character at a time:
Code:
Dim iChar As OneChar
Dim iFileNum As Integer
Dim iRecLength As Long
Dim iLastRec As Long
iRecLength = Len(iChar)
iFileNum = FreeFile
Open "yourfile.txt" For Random As iFileNum Len = iRecLength
iLastRec = FileLen("yourfile.txt") / iRecLength
Then you loop through the records(actually characters) using the Get Statement.
Code:
For x = 1 To iLastRec
Get #iFleNum, x, iChar
Next x
Hope that works..
------------------
Boothman
There is a war out there and it is about who controls the information, it's all about the information.
[This message has been edited by Boothman_7 (edited 01-25-2000).]
-
Jan 25th, 2000, 07:04 AM
#5
Thread Starter
Junior Member
will that method work with binary access? because if i open it with random i will not be able to read EOF, of which there will be several scattered through the file.
-
Jan 26th, 2000, 04:38 PM
#6
Thread Starter
Junior Member
tried to do a
Code:
Dim MyVar as OneByte
didnt work ;P
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|