Difference between WriteByte and WriteAsciiCharacter

Everything else that doesn't fall into one of the other PB categories.
miskox
Enthusiast
Enthusiast
Posts: 108
Joined: Sun Aug 27, 2017 7:37 pm
Location: Slovenia

Difference between WriteByte and WriteAsciiCharacter

Post 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
User avatar
Demivec
Addict
Addict
Posts: 4282
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: Difference between WriteByte and WriteAsciiCharacter

Post 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.
miskox
Enthusiast
Enthusiast
Posts: 108
Joined: Sun Aug 27, 2017 7:37 pm
Location: Slovenia

Re: Difference between WriteByte and WriteAsciiCharacter

Post by miskox »

Thanks.

Just what I thought.

Saso
Post Reply