|
-
Jul 18th, 2001, 03:17 AM
#1
Thread Starter
New Member
-
Jul 18th, 2001, 04:47 AM
#2
Fanatic Member
I believe the "out of memory" error is a result of how the file is delimited. I know nothing of UNIX, but from what you say, it seems that new lines are separated only by a linefeed, Chr$(10), character. Line Input treats a line as everything up to a vbCrLf, which is a Chr$(13) & Chr$(10) combo. If that's true, that Line Input statement is attempting to read the whole file, as it will probably never encounter the 13 10 combo in that order. This will do your conversion.
VB Code:
Dim i As Long
Dim b As Byte
Open "c:\unix.log" For Binary As #1
Open "c:\converted.log" For Binary As #2
For i = 1 To LOF(1)
'read a byte
Get #1, , b
'if it was a linefeed, stick in a carriage return next
If Chr$(b) = vbLf Then Put #2, , vbCr
'now write the byte. any 10 has been converted to the proper 13 10 combo
Put #2, , b
Next i
Close #2
Close #1
For your second question, you can use the function Split() to break up the string at a specified character like space or tab, or even a group of characters.
VB Code:
Dim astrPieces() As String
astrPieces = Split("this is my string"," ")
'astrPieces(0) = "this"
'astrPieces(1) = "is" and so on
I'm baaaack...
VB5 Professional Edition, VC++ 6
Using a 1 gHz Thunderbird, 256 mb RAM, 40 gb HD system with Win98se
I feel special because I finally figured out how to loop midis: Post link
I'm a fanatic too 
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
|