Path: news.daimi.aau.dk!poe From: Peter Andersen Newsgroups: comp.lang.beta Subject: Re: Globals & External C Lib Date: 11 May 1995 14:34:59 GMT Organization: DAIMI, Computer Science Dept. at Aarhus University Lines: 50 Approved: mailtonews@daimi.aau.dk Distribution: world Message-ID: <3ot7aj$9lk@belfort.daimi.aau.dk> NNTP-Posting-Host: daimi.daimi.aau.dk Baiss E. Magnusson writes: > > I'm not clear on how to set up the Beta code to make a call to an > external 'C' library routine that wants the address of a variable passed > ( i.e. call by reference rather than call by value). Just a simple > example of a 'C" routine that uses the address of an > would suffice. As in the call to below: .... One way to do this is: 1. Declare a CStruct specialization which behaves as a short: ShortRef: Cstruct (# byteSize:: (# do 2->value #); value: signedShort(# pos::(# do 0 -> value #)#); enter value exit value #); (actually the final binding of pos is not needed, since the default value will be 0 anyway - here I added it for clarity). 2. Declare GetIMAXXType to use shortRef as parameter: GetIMAXXType: external (# bType: ^ShortRef; enter bType[] do callC #); You probably do not have to exit the bType also, since when transferred by reference you can change it directly in the external. 3. The call would then be: boardType: @ShortRef; do boardType[] -> GetIMAXXType; I hope this works for you. Sincerely, Peter Andersen _____________________________________________________________________________ Mjolner Informatics Aps Phone: (+45) 86 20 20 00 ext. 2753 Science Park Aarhus Direct: (+45) 86 20 20 11 - 2753 Gustav Wieds Vej 10 Fax: (+45) 86 20 12 22 DK-8000 Aarhus C, Denmark Email: peter.andersen@mjolner.dk _____________________________________________________________________________ BETA is better -----------------------------------------------------------------------------