Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!wuarchive!usc!sdd.hp.com!decwrl!sun-barr!newstop!sun!jasonf From: jasonf@cetemp.Eng.Sun.COM (Jason Freund) Newsgroups: comp.lang.pascal Subject: Re: Sun Pascal: Pascal calls C Keywords: Pascal Sun C Message-ID: <141455@sun.Eng.Sun.COM> Date: 28 Aug 90 16:21:18 GMT References: <141406@sun.Eng.Sun.COM> <1561@seti.inria.fr> Sender: news@sun.Eng.Sun.COM Organization: Sun Microsystems, Mt. View, Ca. Lines: 56 I changed the code to use "chdir()", compiled it with "cc -c system_cd.c", compiled it with the pascal main, and it runs without crashing at all. But it still doesn't work. It never actually changes directories. Here's the code: ----------------------------system_cd.c------------------------------- include system_cd (cstr) char *cstr; { chdir(cstr); } - - - - - - - - - - in calling pascal procedure:- - - - - - - - - - - - - procedure system_cd(cstr: string); external c; {is declared as procedure within procedure that calls it} : system_cd(substr(t1,4,length(trim(t1)))); {trim: cuts off trailing spaces, t1 is string, ie "cd test", substr(t1,4,length(trim(t1))) would be "test"} ============================================================================ Also, why doesn't my date function work? I want the system command to get the date and chuck it back into the pascal calling program so that it can be encoded: -------------------------------system_date.c------------------------------ #include system_date (str) char *str; { sprintf(str, (system("/usr/bin/date"))); } - - - - - - - - - - in calling pascal procedure:- - - - - - - - - - - - - procedure system_date(var s: string); external c; : : system_date(s); writeln(s); ...gets: *** Program execution terminated by segmentation violation ???() ???() In system_date () ... after I compile and run it. ---------------------------------------------------------------------------- Any ideas for either case? I'm using Sun Pascal 2.0, on a 3/50 OS 4.1 machine. Jason Freund