Page 1 of 1

Difference between WriteByte and WriteAsciiCharacter

Posted: Sat Mar 02, 2019 10:42 pm
by miskox
Hello!

Manual says that .b has a value between -128 and +127, .a has values between 0 and 255 (all inclusive of course).

Manual also says that WriteByte writes 1 byte and also WriteAsciiCharacter writes 1 byte.

So why are there two commands if they do the same?

Code: Select all

b.b=255
a.a=255
c.b=-1

CreateFile (1,"testa.txt")
MessageRequester ("a",Str(a))
WriteByte (1,a)
CloseFile (1)

CreateFile (2,"testb.txt")
MessageRequester ("b", Str(b))
WriteAsciiCharacter (2, b)
CloseFile (2)

CreateFile (3,"testc.txt")
MessageRequester ("c", Str(c))
WriteByte (3, c)
CloseFile (3)

Files are identical (0xff is written in them).

So if I want to write 1-byte value (0..255) to a file it does not matter which statement I use?
If I want to do some calculactions I must use .a because (as you can see from b.b=255 the actual value is -1*) calculations would be incorrect?

Thanks.
Saso

* I know about the sign bit

Re: Difference between WriteByte and WriteAsciiCharacter

Posted: Sat Mar 02, 2019 11:39 pm
by Demivec
miskox wrote:So why are there two commands if they do the same?
There are two commands for the sake of completeness, a command for each basic dayatype.

The data is the same at the bit level and only differs at the interpretation level (what the bits represent). That is why the files created are the same bur making comparisons or calculations with the respective types can produce results that differ.

Re: Difference between WriteByte and WriteAsciiCharacter

Posted: Mon Mar 04, 2019 8:35 pm
by miskox
Thanks.

Just what I thought.

Saso