|
-
Jun 26th, 2001, 08:22 PM
#1
Thread Starter
Lively Member
Put statement adding 4 extra bytes. Why?
I am working with files in binary access mode to edit ID3 tags. When appending the new tag to the end of the file, the "put" statement is adding 4 extra characters. In this order it adds[backspace][space][end of text][space] so that I end up with
[mp3 data][4 extra bytes][tag]
This works fine except that my file grows 4 bytes larger each time I do it. Is there a way to fix or avoid this?
Thanks to anyone willing to help!
-
Jun 26th, 2001, 08:30 PM
#2
I had a similar problem to the one you are describing. I worked it out to be Visual Basic storing a 4-byte identifier of what you are saving, ie. if you are saving a variant it has four bytes saying 'the next bit of data is a variant' .. I worked my way around it two ways:
1) (not sure if this will solve your problem) Make sure you have something like 'Dim Tag as String' so you aren't using variants.
2) I wrote a small function called dscPut() which I use every so often where speed is not important..
Public Function dscPut(Data as string, Fn as integer)
Dim B as byte
For X = 1 to Len(Data)
B = Asc(Mid(Data,X,1))
Put #Fn, , B
Next X
End Function
It's not the fastest code (I know) or the most efficient (I know that too) but I came up with it early last year and because it is just fine for what I want to do with it I haven't gone back and changed it.
Hope this helps.
-
Jun 26th, 2001, 09:43 PM
#3
Thread Starter
Lively Member
Hey thanks Aurilus! You helped me see exactly what the problem was. I goofed and didn't dim one of my variables that I was using to build my TAG string. After doing so, my problem was solved. I appreciate the help.
-
Jun 26th, 2001, 10:47 PM
#4
Yep.. I think Option Explicit is the most important thing you can do in a Visual Basic form/module... hence my semi-official motto being 'Option Explicit: Accept No Variants'
Glad I could be of help. You could also merge gaffa's and my code, so that instead of storing the data from the file in the other combo boxes you could store it in an array. If you are unsure of how to do this just let me know and I'll be glad to help 
Thanks,
- Aurilus
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
|