run_phc := proc(phcloc::string,p::list)
  description `Calls phc from Maple6 or 7 session. \
The name of file with the executable version of phc \
should be provided in the string phcloc. \
The second input argument p is a list of polynomials. \
On return is a list of approximations to all isolated \
roots of the system defined by p.`:
  local i,n,sp,semcol,sr,infile,outfile,solfile,cmd1,cmd2,sols:
  n := nops(p):             # number of polynomials
  semcol := `;`:
  sr := convert(rand(),string):
  infile := input||sr:      # randomized file names
  outfile := output||sr:
  solfile := sols||sr:
  fopen(infile,WRITE):
  fprintf(infile,`%d\n`,n):
  for i from 1 to n do
    sp := convert(p[i],string):
    sp := StringTools[SubstituteAll](sp,"e","E");   # only in Maple 7
    sp := ` `||sp||semcol:  # append semicolon
    fprintf(infile,`%s\n`,sp):
  od:
  fclose(infile):
  cmd1 := phcloc||` -b `||infile||` `||outfile:
  cmd2 := phcloc||` -z `||outfile||` `||solfile:
  ssystem(cmd1):
  ssystem(cmd2):
  read(solfile): sols := %:
  fremove(infile):
  fremove(outfile):
  fremove(solfile):
  RETURN(sols);
end proc:
