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
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.
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.
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
Been there, got that, LOL! I **know** Arial supports those characters, because I verified the Unicode values against the Windows "Character Map" utility.
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
Thanks!
;D
That caveat about PRINT being ASCII only needs to be in the help file.
Uh, why can't I find TextOutW in the help file?
???
...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.