What the problem boils down to is that an instructor here gave
a lab assignment. It required the use of a sort. Since the project can
be done in C or PASCAL on a UNIX (sun) system, It became evident that
one could use the UNIX sort in a call from C.
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.
You see there is an angry group of my peers waiting to lynch me.
Please HELP ASAP!
Thanks
Soon to be laid to rest.... Mike S.
se...@quanta.eng.ohio-state.edu
-=-
-=-
-Mike Segel se...@icarus.eng.ohio-state.edu (614) 294-3350
"These opinions are my own and in no way reflect those of the University
or the E E Dept.(Although there are those who probably share them!)
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
Actually, now that I think about it, I don't believe that the date pointer has
to be allocated. I believe that the system allocates it for you, but I can't
remember (a bit fuzzy up there).
Kent