May 09, 2024, 05:49:42 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


What is wrong with this sample code?

Started by v_ung_usa, April 26, 2008, 09:27:21 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

v_ung_usa

The following sample code is supposed to open a window and display 4 numbers and the 4 Unicode (card suit) characters.
What did I do wrong?  And what do I need to do in order to get the desired results?

DEF j as INT
DEF w1 as WINDOW
OPENWINDOW w1,0,0,350,350,@HSCROLL|@VSCROLL|@MINBOX|@MAXBOX|@SIZE,NULL,"Simple Window",&main
SETFONT w1,"Arial",20,400,0x00010000
for i=1 to 4
GETDATA suits,j
print w1,wchr$(j)
next i
DATABEGIN suits
DATA 0x2660,0x2663,0x2665,0x2666
DATAEND
WAITUNTIL w1 = 0
END
'---
SUB main
    IF @MESSAGE = @IDCLOSEWINDOW
        CLOSEWINDOW w1
    ENDIF
RETURN
ENDSUB

pistol350

April 27, 2008, 03:29:23 AM #1 Last Edit: April 27, 2008, 03:31:22 AM by pistol350
I can't compile the code now, but what i see is that you use the PRINT command without the MOVE command,
so i guess this is the main reason why anything is displayed.
Regards,

Peter B.

v_ung_usa

Does not help.  I replaced the print statement in the above example with the following 2 lines of code:

move w1, 0,(i-1)*30
print w1,j,wchr$(j)

The result is 4 lines of whatever "J" is, but no "WCHR$(J)" output.

billhsln

I am not 100% sure, but I don't think Arial has the full Unicode character set.  I have tried using a Character set that says it is Unicode, but all I end up with is '?' for each character.

Plus, the only way I am getting '?'s is by doing:

print w1,w2s(Wchr$(j))

Bill
When all else fails, get a bigger hammer.

v_ung_usa

Been there, got that, LOL!  I **know** Arial supports those characters, because I verified the Unicode values against the Windows "Character Map" utility.

Ionic Wind Support Team

PRINT only supports ANSI characters, when you use w2s you are converting a unicode character to ansi, which doesn't have equivelents to those special characters so you get a ?

You need to use the API function TextOutW...


DECLARE IMPORT, TextOutW(uint hdc, int x, int y, wstring str, int count)

DEF j as WORD
DEF hdc as UINT
DEF w1 as WINDOW
OPENWINDOW w1,0,0,350,350,@HSCROLL|@VSCROLL|@MINBOX|@MAXBOX|@SIZE,NULL,"Simple Window",&main
SETFONT w1,"Arial",20,400
hdc = GetHDC(w1)
for i=1 to 4
GETDATA suits,j
TextOutW(hdc,0,0,wchr$(j),1)
next i
ReleaseHDC w1,hdc

WAITUNTIL w1 = 0
END
'---
SUB main
    IF @MESSAGE = @IDCLOSEWINDOW
        CLOSEWINDOW w1
    ENDIF
RETURN
ENDSUB

DATABEGIN suits
DATA 0x2660,0x2663,0x2665,0x2666
DATAEND


Paul
Ionic Wind Support Team

v_ung_usa

Thanks!
;D
That caveat about PRINT being ASCII only needs to be in the help file.

v_ung_usa

Uh, why can't I find TextOutW in the help file?
???

v_ung_usa

...because TextOutW is a Windows API function...

Ok, so I think a caveat about PRINT is in order for the help file and perhaps a mention of how to do itusing TextOutW.