[Solved] PB 5.60: Bug? String variable for Messagerequester

Just starting out? Need help? Post your questions and find answers here.
Klonk
Enthusiast
Enthusiast
Posts: 173
Joined: Tue Jul 13, 2004 2:17 pm

[Solved] PB 5.60: Bug? String variable for Messagerequester

Post by Klonk »

Hi everyone,

is this a bug or am I doing something completely wrong?

Some partial code which shows the problem (BTW: worked with PB 5.40)

Code: Select all

    ;...
    Restore Helptext
    Read linecount.b
    For i=1 To linecount
     Read.s tmp$
     text$ = text$ + tmp$ + Chr(13) + Chr(10)
    Next i
    MessageRequester("tst",text$) ;Text is shown as chinese?
    MessageRequester("tst","Txt") ; text is shown as it should   
    ;...

DataSection
  Helptext:
    Data.b 5
    Data.s "Test1"
    Data.s "Test2"
    Data.s "Test3"
    Data.s "Test4"
    Data.s "Test5"
EndDataSection
It looks like the string in variable text$ is treated as unicode.

Compiled on Win10 Pro 64bit with PB 5.60 32bit

Any ideas?
Last edited by Klonk on Thu Jul 20, 2017 4:18 pm, edited 1 time in total.
Bye Karl
User avatar
kenmo
Addict
Addict
Posts: 1967
Joined: Tue Dec 23, 2003 3:54 am

Re: PB 5.60: Bug? String variable for Messagerequester

Post by kenmo »

Code: Select all

Read.b linecount.b
If you don't specify Read.TYPE, it assumes Read.i, it doesn't matter that your final destination is a .b variable

So it's reading an integer (4 or 8 bytes) instead of 1 byte, and your data pointer is ending up 3 or 7 bytes into the Unicode text, so you're not on an even character boundary, which appears as incorrect Unicode characters when Read as a string. :)


Maybe the Read behavior changed when the Define behavior recently changed.
Klonk
Enthusiast
Enthusiast
Posts: 173
Joined: Tue Jul 13, 2004 2:17 pm

Re: PB 5.60: Bug? String variable for Messagerequester

Post by Klonk »

Such small mistakes make such big problems. tssss...

Many thanks. Sometimes im blind.... :D
Bye Karl
User avatar
kenmo
Addict
Addict
Posts: 1967
Joined: Tue Dec 23, 2003 3:54 am

Re: PB 5.60: Bug? String variable for Messagerequester

Post by kenmo »

It's an understandable mistake. You're reading into a .b variable, so it's easy to assume the compiler will only read 1 byte.

Maybe the help should make this more clear.
Post Reply