#
# @(#)vms.icn	1.6 5/5/90
# OS-specific code for VMS Idol
#
global icontopt,cd,md,env,sysok

procedure mysystem(s)
  if \loud then write(s)
  return system(s)
end

procedure filename(s,ext)
  s[9:0] := ""
  s ||:= \ext
  return s
end
# if the filename s has extension ext then return the filename less the
# extension, otherwise fail.
procedure fileroot(s,ext)
  if s[- *ext : 0] == ext then return s[1 : - *ext]
end
procedure writesublink(s)
  writelink(env||s)
end
procedure envpath(filename)
  return env||filename
end
#
# Installation.
# Uses hierarchical filesystem on some systems (see initialize)
#
procedure install(args)
  write("Installing idol environment in ",env)
  if env ~== "" then mysystem(md||env)
  fout := envopen("i_object.icn","w")
  write(fout,"record idol_object(__state,__methods)")
  close(fout)
  fout := &null
  cdicont(["i_object"])
end
procedure uninstall(args)
  # not implemented yet
end

procedure makeexe(args,i)
  exe := args[i]
  if icont(exe) = \sysok then {
      mysystem("del "||exe||".icn")
      if \exec then {
	write("Executing:")
	exe := "iconx "||exe
	every i := exec+1 to *args do exe ||:= " "||args[i]
	mysystem(exe)
      }
  }
end
#
# system-dependent compilation of idolfile.icn
#   (in the idol subdirectory, if there is one)
#
procedure cdicont(idolfiles)
  if comp = -2 then return  # -t --> don't icont at all
  args := " -c"
  rms  := ""
  every ifile := !idolfiles do args ||:= " " || ifile
  every ifile := !idolfiles do rms  ||:= " " || ifile || ".icn"

  every ifile := !idolfiles do mysystem("@vms "||ifile||".icn")
  return
end

procedure sysinitialize()
    icontopt := " \"-Sr500\" \"-Si1000\" \"-SF30\" \"-Sg500\" "
    cd    := "set default "
    md    := "create/dir "
    env := getenv("IDOLENV") | "[.idolenv]"
    sysok    := 1
end
