Path: news.cs.au.dk!Morten.Grouleff.Mjolner.Informatics From: Morten Grouleff Newsgroups: comp.lang.beta Subject: Re: MB_YESNOCANCEL, MB_YESNO, MB_RETRYCANCEL ... Date: 01 Mar 1999 13:18:37 +0100 Organization: Mjolner Informatics. Lines: 58 Message-ID: References: <19990301093451.1650.qmail@noatun.mjolner.dk> NNTP-Posting-Host: hugin.mjolner.dk Mime-Version: 1.0 (generated by tm-edit 7.106) Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: xinwen.cs.au.dk 920290717 7989 255.255.255.255 (1 Mar 1999 12:18:37 GMT) X-Complaints-To: news@cs.au.dk NNTP-Posting-Date: 1 Mar 1999 12:18:37 GMT X-Newsreader: Gnus v5.5/Emacs 19.34 Xref: news.cs.au.dk comp.lang.beta:11851 "Sascha Kimmel" writes: [...] > And could someone please explain how to implement certain WINAPI functions > like the following one in BETA? > > BOOL GetUserName( > LPTSTR lpBuffer, // address of name buffer > LPDWORD nSize // address of size of name buffer > ); win32lib/winbase.bet: (* BOOL WINAPI GetUserNameA (LPSTR lpBuffer,LPDWORD nSize ); *) GetUserName: external (# name: @integer; length: @integer; result: @boolean; enter (name, length) do 'GetUserNameA' -> callStd; exit result #); > My problem is that I don't know how to get the address of a variable. > Adresses and addresses.. well, yes, it's C :) You really should not get the address of an attribbute of a BETA object, as it may be changes by the garbage collector. But there are other ways...: ORIGIN '~beta/basiclib/betaenv'; INCLUDE '~beta/sysutils/cstring'; INCLUDE '~beta/win32lib/winbase'; --PROGRAM: descriptor-- (# cs: @CString; lgt, result: @Integer; do 256->lgt; lgt->cs.init; (cs, @@lgt)->GetUserName->result; (if result<>0 then cs.get->screen.putLine; if); cs.free; #) Here, CString is used to store the string. @@lgt is the address of the integer lgt. Note that this code is safe, but only because the address is only used in a call of an external function. Using @@lgt in any other way leads to unpredictable errors. This is not a supported part of the implementation and may change without notice. Regards, -- ** Morten Grouleff: ** ** Earthworm Jim PC: ** ** Mjølner Informatics: **