Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!swrinde!kent From: kent@swrinde.nde.swri.edu (Kent D. Polk) Newsgroups: comp.lang.pascal Subject: Re: How do you make a system call from PASCAL? Keywords: UNIX SYSTEM CALL Message-ID: <16274@swrinde.nde.swri.edu> Date: 16 May 89 17:02:41 GMT References: <2167@quanta.eng.ohio-state.edu> Reply-To: kent@swrinde.UUCP (Kent D. Polk) Distribution: usa Organization: Southwest Research Institute, San Antonio, Texas Lines: 61 In article <2167@quanta.eng.ohio-state.edu> segel@muon.eng.ohio-state.edu (Gargoyle) writes: > > HELP! > Since I am not a normal PASCAL user, If you have a response, could >you please e-mail it to me ASAP? Also This is being posted 5/12/89. Please >do not respond after 5/16/89. > [...] > Is there such a call from PASCAL? Or >do I have to write a C program to make the call, then have the PASCAL >program call that C subroutine? I know this can be done, but is there >a simpler solution. > >-Mike Segel segel@icarus.eng.ohio-state.edu (614) 294-3350 While I haven't done this on a Sun, I have extensively on HP-UX/HP Pascal, so I don't know whether it would apply. Pascal variable parameter passing is just like C's passing an address. Thus, for instance, to call ctime or nl_ctime, one would do something like: {*********************************} Type datestr = Packed array [0..25] of Char; datestr_ptr = ^datestr; { Forward External References } Function ctime (Var nsec: Integer): datstr_ptr; External; Function nl_ctime (Var nsec: Integer; Var format: string): datstr_ptr; External; Function time (Var ds: Integer): External; Var date : datestr_ptr; secs : integer; Begin time (secs); New(date); If (format specified) then date := nl_ctime (secs, format) Else date := ctime (secs); {cleanup the string for pascal as desired} dispose(date); End; Now, exec'ing a program is done in a similar way, however, due to Pascal limitations with file descriptors, I usually find that this is done easier with a small C module which you declare as external & pass the name of the file to exec'ed to it. If in doubt about the size of a record or structure, most compilers can be persuaded to divilge such info to make sure you have everything described properly & $include (header file describing the record structure in pascal) Disclaimer : This is all from memory & I haven't done this in a couple of years, but it ought to be close. Lots of fun. Ought to try shared mem/message handling from Pascal next. :^) Kent Polk