Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Name Length in Binary
#1
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?
Reply
#2
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.
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply
#3
Ah I see, good point Tongue
Reply
#4
Dave Wrote:If you saved them as null-terminated strings, you can read in one byte at a time until you reach the null termination Big Grin

C++ ftw
You don't mean ftw, you mean WTF Tongue
Reply
#5
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
Reply
#6
In my case Im just using
Code:
Put Item(num)
So Im not saving each part on their own.
Reply
#7
Yeah, so that should work fine with variable-length strings.
Reply
#8
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.
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)