| Apply Mode 2.0
| Run
| G.C.W. & F.J.G. (1/6/03)

| Ensure no script language is set
Unset StrongED$Script_Language

| Create some handy variables
Set StrongED$Script_Script  %0
Set StrongED$Script_ToolDir <Obey$Dir>
Set StrongED$Script_Infile  <StrongED_Scrap$Dir>.out
Set StrongED$Script_Outfile <StrongED_Scrap$Dir>.in

| First try to determine script language from filetype
Run <StrongED$Script_ToolDir>.?ftype <StrongED$Script_Script>

| Set script language if it's a known filetype
If "<StrongED$Script_Filetype>" = "FFB" Then Set StrongED$Script_Language "basic"
If "<StrongED$Script_Filetype>" = "AE5" Then Set StrongED$Script_Language "python"
|If "<StrongED$Script_Filetype>" = "400" Then Set StrongED$Script_Language "forth"

| If filetype didn't work see if the file starts with #!language
If "<StrongED$Script_Language>" = "" Then Run <StrongED$Script_ToolDir>.?language <StrongED$Script_Script>

| If we still haven't got a language then report an error
If "<StrongED$Script_Language>" = "" Then Error Unable to determine script language for <StrongED$Script_Script>

| Now run the script using the correct syntax for the language specified
If "<StrongED$Script_Language>" = "awk"    Then awk  -f <StrongED$Script_Script> <StrongED$Script_Infile> > <StrongED$Script_Outfile>
If "<StrongED$Script_Language>" = "basic"  Then Run     <StrongED$Script_Script> <StrongED$Script_Infile> > <StrongED$Script_Outfile>
If "<StrongED$Script_Language>" = "lua"    Then lua     <StrongED$Script_Script> <StrongED$Script_Infile> > <StrongED$Script_Outfile>
If "<StrongED$Script_Language>" = "perl"   Then perl -- <StrongED$Script_Script> <StrongED$Script_Infile> > <StrongED$Script_Outfile>
|If "<StrongED$Script_Language>" = "forth"  Then Run     <StrongED$Script_Script> <StrongED$Script_Infile> > <StrongED$Script_Outfile>
|If "<StrongED$Script_Language>" = "python" Then python  <StrongED$Script_Script> <StrongED$Script_Infile> > <StrongED$Script_Outfile>
|If "<StrongED$Script_Language>" = "sed"    Then sed  -f <StrongED$Script_Script> <StrongED$Script_Infile> > <StrongED$Script_Outfile>

| Ensure that Outfile is of type text
Settype <StrongED$Script_Outfile> text

| Tidy up
Unset StrongED$Script_Script
Unset StrongED$Script_ToolDir
Unset StrongED$Script_Infile
Unset StrongED$Script_Outfile
Unset StrongED$Script_Filetype
Unset StrongED$Script_Language
