![]() |
Name Length in Binary - Printable Version +- Mirage Source (https://mirage-engine.uk/forums) +-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61) +--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18) +---- Forum: General (https://mirage-engine.uk/forums/forumdisplay.php?fid=17) +---- Thread: Name Length in Binary (/showthread.php?tid=1340) |
Name Length in Binary - William - 13-10-2007 So, I've got all my items setup and finished through the item editor. But, I noticed before that the name length was set to 20 so I couldn't get all the full names written out. So I just thought, I'll fix that later. But now when I tried to set it to 30, basicly the binary file doesn't know what to load really. Since its set as a fixed lentgh in the file. So I can't change that without remaking all my items. Do anybody have an idea how to fix this, without remaking all the 100 items? Re: Name Length in Binary - Robin - 13-10-2007 Load them into a type with 20 set length, then re-save them to a different type with 30 set length, and save them. Basically just a converter. Re: Name Length in Binary - William - 13-10-2007 Ah I see, good point ![]() Re: Name Length in Binary - William - 13-10-2007 Dave Wrote:If you saved them as null-terminated strings, you can read in one byte at a time until you reach the null terminationYou don't mean ftw, you mean WTF ![]() Re: Name Length in Binary - Spodi - 13-10-2007 Most any language that can perform file I/O can create null-terminated strings. :wink: I prefer string size headers myself, since you can define the length then grab the whole string at once instead of this "one byte at a time" stuff. What Robin said, though, would be the easiest approach. Though, why is there so many fixed length strings anyways? I can't really see it being for performance with so many string functions used like Trim$(), Left$(), Right$() and Mid$(), and it just ends up taking more RAM unless you actually use the defined length every time (which I doubt). I have never had problems with binary file I/O in VB6 with variable-length strings when just using: Put #x,, MyTypeWithMyString or Put #x,, MyString Re: Name Length in Binary - William - 13-10-2007 In my case Im just using Code: Put Item(num) Re: Name Length in Binary - Spodi - 13-10-2007 Yeah, so that should work fine with variable-length strings. Re: Name Length in Binary - Robin - 13-10-2007 Don't variable length strings have the length stored in them anyway? And just for your information, you only really need to use set length strings if you're saving all the maps to the same file or something and you're setting the start byte. But that's only if you don't bother to dynamically change the start byte depending on the stored data for the different maps instead of working the "set" length of the map data manually. |