|
-
Mar 26th, 2003, 03:28 PM
#1
Reading a text file wrong....
Sorry for the bad gode I have posted, but this is just a test. I am going to read a text file and splitt it up into an array, but something is wrong with the file reading...it skipps a lot of spaces. Open the text tile in notepad to see how it should be...
Cut and paste link:
http://www.geocities.com/note_ladybug/word.zip
-
Mar 26th, 2003, 03:34 PM
#2
Stuck in the 80s
From that link I get:
We're sorry, but this page is currently unavailable for viewing.
If this site belongs to you, please read this help page for more information and assistance.
For general questions see our main help area, or search for other member pages.
Try attaching it instead?
-
Mar 26th, 2003, 03:35 PM
#3
Sorry to big...nearly 200k....did you cut and paste the link Hobo?
-
Mar 26th, 2003, 03:37 PM
#4
Stuck in the 80s
Originally posted by NoteMe
Sorry to big...nearly 200k....did you cut and paste the link Hobo?
No...why is it so big?
-
Mar 26th, 2003, 03:38 PM
#5
It was a dictionary that is 1Mb zipped down to 100k + the app... myabe I can cheat and post it in two posts?
-
Mar 26th, 2003, 03:42 PM
#6
OK..now I think it is working...try the link...
http://www.geocities.com/note_ladybug/word.zip
-
Mar 26th, 2003, 03:43 PM
#7
The link wasn't properly cased, here's the correct one: http://www.geocities.com/note_LadyBug/word.zip
The problem is, the file contains null characters (Chr(0)), resulting in the data being cut off.
When you open this in Notepad, it converts them to spaces, I suggest you do the same thing.
-
Mar 26th, 2003, 03:45 PM
#8
Thanks there....
but will I have to read the file first into a string, then replace all teh (Chr(0)) with spaces, and then print out?
-
Mar 26th, 2003, 03:48 PM
#9
OK...what do you actuall mean now?
VB Code:
Buffer = Replace(Buffer, Chr(0), " ")
??
-
Mar 26th, 2003, 03:48 PM
#10
You need to convert them to spaces prior to splitting it into an
array or anything else that might interpret the null charcters as
the end of the line/string.
VB Code:
Public Function fnFileToStr(ByVal sFile As String) As String
Dim iFile As Integer
Dim sBuffer As String
iFile = FreeFile
Open sFile For Binary Access Read As iFile
sBuffer = Space(LOF(iFile))
Get #iFile, , sBuffer
Close iFile
fnFileToStr = sBuffer
End Function
Example:
VB Code:
sString = Replace(fnFileToStr("eng_nor.wb"), chr(0), " ")
-
Mar 26th, 2003, 03:56 PM
#11
Thanks Aaron Young, you are todays saver....it didn't help with just using the replace function as in my last post. So I tried binary reading as in your post, and everything worked as it should. I think that if I use the other way of reading the text file it just converts the chr(0) to "" automaticaly when it read the text. So again thanks....
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
|