Binary file write - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3) +---- Forum: Help Me! (https://qb64phoenix.com/forum/forumdisplay.php?fid=10) +---- Thread: Binary file write (/showthread.php?tid=2025) |
Binary file write - eoredson - 09-23-2023 Here is some annoying code for you: Code: (Select All) Type struct Code: (Select All) Dim x2(1 To 1024) As String Erik. RE: Binary file write - mnrvovrfc - 09-23-2023 LOL. VLS member inside UDT. Object-oriented programming in QB64, here we come! The array of strings problem you presented is for the simple reason that it will have to write the lengths of the string, at the time the file is being created and written to. Otherwise how are you going to tell one string member from another later? By making all members of a specific length, you are helping the QB64 compiler indicate where one string starts and where it ends, out of many thousands potentially. Much binary code must store the length of the string first of all before writing the string. This is the only way (at a low level) to reliably bring back data to the state it was when a file had to be created to hold those strings and other stuff. What are you trying to do with the array of VLS's anyway? Just create an UDT which in the least, there is an integer length, and the other member is a fixed-length string. Must make the string as large as you think a single string member could be. It sucks, but that is the most sane way to go about things. RE: Binary file write - eoredson - 09-23-2023 Quote:What are you trying to do with the array of VLS's anyway?I have a Screen Editor dimensioned a large array I am writing to the file using binary write variable length string array which is slow. Binary write because Linux might strip 013 ascii from the file. For example: Code: (Select All) Linux = -1 Note: You cannot Put 1,,Chr$(10) or Put 1,,Asc(Chr$(10)) RE: Binary file write - bplus - 09-23-2023 VLS variable length strings is old known problem for QB64 as well as arrays in UDT. There are work arounds as old as this problem. You're right! I am annoyed you bringing this up this old thing again. ;-)) It's like I am lazy and people keep coming up to me and saying, Hey, you're lazy! RE: Binary file write - bplus - 09-23-2023 (09-23-2023, 03:57 AM)eoredson Wrote:Quote:What are you trying to do with the array of VLS's anyway?I have a Screen Editor dimensioned a large array I am writing to the file using binary write variable length string array which is slow. Ah now we get to real problem! Trying to please Linux and all it's possible flavors. Well I leave that up to @mnrvovrfc ;-)) like that's not old too LOL RE: Binary file write - mnrvovrfc - 09-23-2023 It's not that difficult. Code: (Select All) DIM ff AS LONG Or could check result of `_OS$()` function. For an executable it doesn't matter because the three main operating systems use different formats: Linux uses ELF. RE: Binary file write - eoredson - 09-24-2023 Quote:Trying to please Linux and all it's possible flavors.Out of all the 50+ linux os variants I don't think I could even touch every flavor Why they cut out 013 in the first place still bothers me. RE: Binary file write - SMcNeill - 09-24-2023 Even Windows removes the 13 now. I tend to just write all CRLF as 10 and be done with it, anymore. RE: Binary file write - SpriggsySpriggs - 09-25-2023 I only ever mess with CHR$(10) in both Windows and Linux. It displays just fine in both. Don't see any reason to do a carriage return & line feed combo on Windows. Just do the line feed. No need to complicate matters with checking for OS$. RE: Binary file write - eoredson - 09-26-2023 On the subject of CRLF I have wrote the following set of TEE utilities: Erik. |