set fonts(n) Trinity.Medium
set fonts(i) Trinity.Medium.Italic
set fonts(b) Trinity.Bold
set fonts(t) Corpus.Medium
set fonts(a) Sassoon.Primary

set colours(red) 255:0:0
set colours(green) 0:255:0
set colours(blue) 0:0:255
set colours(yellow) 255:255:0
set colours(cyan) 0:255:255
set colours(magenta) 255:0:255
set colours(white) 255:255:255
set colours(black) 0:0:0
set colours(grey) 127:127:127

# define some global variables
set line ""
set fid 0
set win 0
set licencename ""
set licencedate "010195"
set searchname ""

# The next lines define global flags that could be set to 1
# if the option should be on at start
set debugflag 0
set traceflag 0
set profileflag 0
set clockflag 0
set serialflag 0
set blockflag 0
set optimizerflag 0
set compatibleflag 0
set w_file "risc_os\.auto"
set binsizevar "Large"
set Licence "Evaluation Version"
set docdriver "ASCII"

# these variables are set according to the !Forthmacs system status and control greying in the menus
set meta 1;    if {[file exists Forthmacs:meta.arm.target]}		{set meta 0}
set docs 1;    if {[file exists Forthmacs:docs.formatt.format]}		{set docs 0}
set develop 1; if {[file exists Forthmacs:private.develop]}		{set develop 0}

if {[file exists Forthmacs:private.Licence]}\
  { set fid [open Forthmacs:private.Licence]; set Licence [gets $fid]; close $fid}


# function declarations
proc setoptions {}\
{ global compatibleflag debugflag traceflag profileflag clockflag serialflag blockflag optimizerflag
  global binsizevar docdriver
  system "seteval Forthmacsoptions 0"
  if {$binsizevar == "Large"} {system "seteval Forthmacsoptions 4096"}
  if {$docdriver  == "LaTeX"} {system "seteval Forthmacsoptions Forthmacsoptions +  8192"}
  if {$docdriver  == "HTML"}  {system "seteval Forthmacsoptions Forthmacsoptions + 16384"}
  system "seteval Forthmacsoptions Forthmacsoptions +       $compatibleflag"
  system "seteval Forthmacsoptions Forthmacsoptions +   2 * $debugflag"
  system "seteval Forthmacsoptions Forthmacsoptions +   4 * $traceflag"
  system "seteval Forthmacsoptions Forthmacsoptions +   8 * $serialflag"
  system "seteval Forthmacsoptions Forthmacsoptions +  16 * $blockflag"
  system "seteval Forthmacsoptions Forthmacsoptions +  32 * $profileflag"
  system "seteval Forthmacsoptions Forthmacsoptions +  64 * $clockflag"
  system "seteval Forthmacsoptions Forthmacsoptions + 128 * $optimizerflag"
  system "set Forthmacsoptions <Forthmacsoptions>"
}

proc archive 		{list} {system "archive $list"}
proc update-archive     {list date } {system "+archive $list $date"}
proc doexit {}\
{ system "Unset ForthmacsTcl"
  system "Unset Forthmacsoptions"
  exit
} 

proc binary {bin}\
{ global binsizevar
  setoptions
  if {$binsizevar == "Large"} {system "Forthmacs:risc_os.bin.run.$bin"}
  if {$binsizevar == "Small"} {system "Forthmacs:risc_os.bin.run.s$bin"}
}

proc compiler {bin}\
{ global binsizevar
  setoptions
  if {$binsizevar == "Large"} {system "Forthmacs:risc_os.bin.load.$bin"}
  if {$binsizevar == "Small"} {system "Forthmacs:risc_os.bin.load.s$bin"}
}

proc runforth {file}\
{ global binsizevar
  setoptions
  if {$binsizevar == "Large"} {system "Forthmacs:risc_os.bin.run.fForth $file"}
  if {$binsizevar == "Small"} {system "Forthmacs:risc_os.bin.run.sfForth $file"}
}

proc clickproc {button}\
{ if {$button == "s"} {system "Filer_OpenDir <Forthmacs\$Dir>"}
  if {$button == "a"} {runforth risc_os.auto}
}

proc showfile {fname}\
{ global line fid win
    set fid [open $fname]
    w_text win$win create -title $fname -width 1200.OS -size 13p
    w_text win$win options -l.1i
    while {![eof $fid]} { set line [gets $fid]; w_text win$win print $line}
    close $fid; w_text win$win open; incr win
}

proc makelicence {name date}\
{  global fid
   system "Copy Forthmacs:private.licence <Forthmacs\$Dir>.private.licence+ ~V~CFD"
   set fid [open <Forthmacs\$Dir>.private.licence w];puts $fid $name;close $fid
   update-archive WorkDiscR $date
   system "Copy Forthmacs:private.licence+ <Forthmacs\$Dir>.private.licence ~V~CFD"
}
 
proc search {name}\
{  system "set tmp\$word $name"
   system "set Forthmacsdocstyle ASCII"
   system "Forthmacs:risc_os.bin.search"
   showfile "Forthmacs:docs.html.searchfile"
   system "unset Forthmacsdocstyle"
}
