![]() |
||
| Home | SwiftForth Archive | SwiftX Archive | |

No need to use VALUEs. When passing an object address to a function,
use the method ADDR.=20
: STARTING
hwnd GetDC=20
DUP TM ADDR GetTextMetrics DROP
TM AveCharWidth @ CXCHAR !
...=20
=20
Mike
-----Original Message-----
From: sftalk-bounce_at_forth.com [mailto:sftalk-bounce_at_forth.com] On Behalf
Of Jason Damisch
Sent: Monday, January 31, 2005 2:58 PM
To: sftalk_at_forth.com
Subject: [sftalk] Isn't there a more tidy way to do this?
I have been reading Petzold a bit and converted a sample program from
C++ to SF. Here is a snipit from my code.
PAINTSTRUCT BUILDS PS
TEXTMETRIC BUILDS TM
0 VALUE 'TM
TM DUP TO 'TM AveCharWidth DROP=20
0 VALUE 'PS
PS DUP TO 'PS DC DROP ( what's the tidy way to do this? )
: STARTING
hwnd GetDC=20
DUP 'TM GetTextMetrics DROP
TM AveCharWidth @ CXCHAR !=20
It works. The funny thing is that when you use the instance of the
class, it changes the search context and puts the address of the
instance on the stack and also expects to find the name of a member
which consumes the instance from the stack. Fair enough but I can't just
use the instance by himself in order to pass him to a Windows function
because SF is still looking for a member. So I give the address to a
VALUE. I use an arbitrary member and then DROP it because all I was
using it for was to tell SF to stop looking for a member. I find that If
I don't do this then I can't use a Windows function. SF acts like it
isn't in the dictionary.
INCLUDE C: ForthInc SwiftForth User sysmets Sysmets1.f GetDC ? hwnd
GetDC At line 76 in C: ForthInc SwiftForth User sysmets Sysmets1.f
Question. Isn't there a more tidy way to do this? I didn't catch it in
the documentation or in any of the source code files.
Thanks!
=09
__________________________________
Do you Yahoo!?=20
Meet the all-new My Yahoo! - Try it today!=20
http://my.yahoo.com=20
=20
----------------------------------------------------------------------
sftalk_at_forth.com The SwiftForth programming discussion email list
To unsubscribe, send subject "unsubscribe" to sftalk-request_at_forth.com
For list command help, send subject "help" to sftalk-request_at_forth.com
Message archives are located at http://www.forth.com/archive/sftalk
----------------------------------------------------------------------
This list is a forum for SwiftForth users. For product support and bug=20
reports, please send email to support_at_forth.com
----------------------------------------------------------------------
----------------------------------------------------------------------
sftalk_at_forth.com The SwiftForth programming discussion email list
To unsubscribe, send subject "unsubscribe" to sftalk-request_at_forth.com
For list command help, send subject "help" to sftalk-request_at_forth.com
Message archives are located at http://www.forth.com/archive/sftalk
----------------------------------------------------------------------
This list is a forum for SwiftForth users. For product support and bug
reports, please send email to support_at_forth.com
----------------------------------------------------------------------
Received on Mon Jan 31 2005 - 16:57:27 PST
This archive was generated by hypermail 2.2.0 : Thu Nov 20 2008 - 03:04:34 PST