PDA

View Full Version : Magic CHR$



Petr Schreiber
30-11-2005, 23:35
Hi,

the CHR$ works as it should, but when using this example based on help file, one can get idea it does nothing :



MSGBOX 0, CHR$(0 TO 131, 97, 133 TO 255)


It seems the problem is caused by the 0 pos. character, because CHR$(1 TO 131, 97, 133 TO 255) will work.

It's just detail.

Thanks,
Psch

RobertoBianchi
01-12-2005, 09:57
Hi Psch,

this funny behaviour it's due to MessageBox() WIN32 API not to CHR$() function.

Try the following script:


dim s as string

s = CHR$(0 TO 131, 97, 133 TO 255)

MSGBOX 0, "Len " + len(s) + $CRLF + "String " + s

s = CHR$(1 TO 131, 97, 133 TO 255)

MSGBOX 0, "Len " + len(s) + $CRLF + "String " + s


Almost all WIN32 API are written in C/C++ so in your sample you just pass the null byte to the MessageBox API.

Regards,
Roberto

ErosOlmi
01-12-2005, 11:03
Yes, in any case Psch suggestion is right.
I will change the example to a more clever one allowing MSGBOX to properly work.

Thanks
Eros