nick@agsm.unsw.oz (Nick Frisina) (11/18/88)
i have empress v2.4 and am using pascal to interface. the call "mxgetvs" has never worked. the evidence is on a vax11-780 running unix sysV. now that i'm porting the lot to an apollo dn4000 running aegis 9.7, not only is the above true BUT there is an added problem of memory corruption such that the "c-code" patch written to make the pascal work on the vax now no longer functions.... any-one out there got the mxgetvs call to work from pascal??? nick
joek@radian.UUCP (Joe Kugler) (11/23/88)
In article <620@agsm.unsw.oz>, nick@agsm.unsw.oz (Nick Frisina) writes: > i have empress v2.4 and am using pascal to interface. > the call "mxgetvs" has never worked. On a project we recently did here at Radian, we made a glue layer between the Empress C interface and pascal. We did this at the mx level. Each mx function had a corresponding pascal function named pmx*. Anyway, we never experienced any problems in passing pointers between our pascal code and the empress mx c functions. For the mxgetvs in question, we did the following. 1.) Created the types Emp_Str = PACKED ARRAY[1..MAXLINE] OF Char; and Emp_Str_Ptr = ^Emp_Str; 2.) Declare the Empress mxgetvs function as [EXTERNAL] FUNCTION mxgetvs( VAR attribute: Emp_Str ): Emp_Str_Ptr; external 3.) The mxgetvs function is called from our Pascal code as rv := mxgetvs( at ); where: rv: Emp_Str_Ptr; and at: Emp_Str; As always, the character after the last meaningful element in the PACKED ARRAY 'at' must be null. That is, if the Emp_Str type is a PACKED ARRAY[1.100] OF char and the attribute is 'name', then 'at' would contain: at[1] = n, at[2] = a, at[3] = m, at[4] = e, at[5] = null at[6] through at[100] aren't used in the mxgetvs function, even if they contain something other than null characters. Even though it appears as if we are passing the string 'at' to mxgetvs, we are actually passing the address, since the formal parameter 'attribute' is declared as VAR in our external declaration of mxgetvs. We also had two primitives, to_cstring and to_pstring, which would allow us to work with VARYING strings in the pascal code and PACKED ARRAYs when we were dealing with Empress calls. So in the above example, we convert the null terminated PACKED ARRAY rv^ to a VARYING string after it is returned by mxgetvs. This was implemented on a MicroVAX II under VMS. Hope this helps. Joe Kugler Radian Corporation e-mail ...!cs.utexas.edu!natinst!radian!joek P.O. Box 201088 Austin, Texas 78720-1088 (512)454-4797 The opinions expressed in this posting are not necessarily those of my employer.