Author Topic: SCI1.1 File::readString first byte  (Read 20 times)

0 Members and 1 Guest are viewing this topic.

Offline doomlazer

SCI1.1 File::readString first byte
« on: Yesterday at 10:43:07 PM »
Consider a text file containing the alphabet. If we use the File class's readString with a max size property of 5 and then print the string, the output is 'abcd', if the max size is 1, then we get a blank text box; max size of 2 results in 'a'.

A hex editor confirms that the first byte of the text file is 0x61 (a), so what's up with that 'empty' first byte in the max size property?

« Last Edit: Today at 01:42:04 AM by doomlazer »



Offline Kawa

Re: SCI1.1 File::readString first byte
« Reply #1 on: Today at 04:11:14 AM »
When I started writing this reply, I figured it could have to do with the simple fact that SCI, at least until the 32-bit versions and even then barely, had no concept of an 8-bit value and thus has to read a multiple of two bytes at a time.

But then I looked at your numbers and results again and now I'm thinking it's a null-terminator issue. You asked for five characters, so you got four + the null terminator. You asked for one character, so you got only the terminator, etc.

After all, you gotta know where to stop reading.


SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.013 seconds with 17 queries.