  rem *******************************************************************
  rem * Code Specifications are as follows:
  rem * REM statements and LABELS must not be indented.
  rem * Vars are limited to what labels are under the :SET procedure,
  rem * use single "%" for 1-9 and a-z, use "%%" for all others
  rem * (only %a - %c  and %%aa - %%cc are used in this example).
  rem * Parameters are limited to 12 max, must use "|" to separate them.
  rem * Strings and numbers/vars must be separated.
  rem *   Example: INFO|This is a string|%a|Another string|40
  rem * You must use the SET command to assign a value to a variable,
  rem * and only use one math/dlgtext function per line.
  rem *   Example: SET|%a|SUM|10|20
  rem *            SET|%b|DLGTEXT|Editbox1
  rem * INFO automatically inserts @cr()@cr() after every 4 parameters.
  rem * IF ELSE END can be nested (don't know how deep yet), but can
  rem * be used only with simple EQUAL,GREATER and MATCH functions.
  rem *******************************************************************
  rem * Commands: -> DIALOG{CREATE,ADD,SHOW,HIDE,SET,CLEAR,SETPOS},
  rem * TITLE, IF, END, ELSE, INFO, SET(assigns var values), GOTO, GOSUB,
  rem * WAIT(w/timer event), All LIST commands except "LOADTEXT".
  rem *******************************************************************
  rem * Functions: DLGTEXT, SUM, DIFF, PROD, DIV, FADD, FSUB, FMUL, FDIV,
  rem * EQUAL, GREATER, MATCH, INDEX, ITEM
  rem *******************************************************************

  OPTION SCALE, 96
  rem -- Variable list --
  LIST CREATE, 7
  rem -- Function list --
  LIST CREATE, 8
  rem -- Normally load script.mac to this --
  LIST CREATE, 9

  LIST LOADTEXT, 9,
"TITLE|By Mac
"DIALOG|CREATE|Test|-1|200|120|165
"  DIALOG|ADD|EDIT|E1|0|5|50|20
"  DIALOG|ADD|EDIT|E2|0|65|50|20
"  DIALOG|ADD|BUTTON|Add|25|5|50|20
"  DIALOG|ADD|BUTTON|Subtract|25|65|50|20
"  DIALOG|ADD|BUTTON|Multiply|45|5|50|20
"  DIALOG|ADD|BUTTON|Divide|45|65|50|20
"  DIALOG|ADD|BUTTON|EqGr|65|5|110|20|"Is equal or greater?"
"  DIALOG|ADD|LIST|L1|90|5|110|50|CLICK
"  DIALOG|ADD|STATUS|Stat|Ready...
"DIALOG|SHOW
"
"LIST|ADD|L1|Click for GOSUB
"LIST|ADD|L1|Any of these will
"LIST|ADD|L1|cause a click
"LIST|ADD|L1|event that does
"LIST|ADD|L1|a simple GOSUB
"LIST|ADD|L1|procedure.
"
":EVLOOP
"  DIALOG|SET|Stat|Ready...
"  WAIT|EVENT
"  DIALOG|SET|Stat|Please Wait...
"  GOTO|EVENT
"
":L1CLICK
"  GOSUB|GSTEST
"  GOTO|EVLOOP
"
":AddBUTTON
"  SET|%a|DLGTEXT|E1
"  SET|%b|DLGTEXT|E2
"  SET|%c|FADD|%a|%b
"rem -- @cr()@cr() is auto inserted every 4 parameters --
"  INFO|"a = "|%a|||"b = "|%b||||"answer = "|%c 
"  GOTO|EVLOOP
"
":SubtractBUTTON
"  SET|%a|DLGTEXT|E1
"  SET|%b|DLGTEXT|E2
"  SET|%c|FSUB|%a|%b
"  INFO|"a = "|%a|||"b = "|%b||||"answer = "|%c 
"  GOTO|EVLOOP
"
"rem -- Using %%aa, %%bb, and %%cc for mult and div --
":MultiplyBUTTON
"  SET|%%aa|DLGTEXT|E1
"  SET|%%bb|DLGTEXT|E2
"  SET|%%cc|FMUL|%%aa|%%bb
"  INFO|"aa = "|%%aa|||"bb = "|%%bb||||"answer = "|%%cc 
"  GOTO|EVLOOP
"
":DivideBUTTON
"  SET|%%aa|DLGTEXT|E1
"  SET|%%bb|DLGTEXT|E2
"  SET|%%cc|FDIV|%%aa|%%bb
"  INFO|"aa = "|%%aa|||"bb = "|%%bb||||"answer = "|%%cc 
"  GOTO|EVLOOP
"
":EqGrBUTTON
"  SET|%a|DLGTEXT|E1
"  SET|%b|DLGTEXT|E2
"  IF|EQUAL|%a|%b
"    INFO|Entries 1 and 2 are the same...
"  ELSE
"    IF|GREATER|%a|%b
"      INFO|Entry 1 is greater than entry 2...
"    ELSE
"      IF|GREATER|%b|%a
"        INFO|Entry 2 is greater than entry 1...
"      END
"    END
"  END
"  GOTO|EVLOOP
"
":GSTEST
"  LIST|SEEK|L1|0
"  IF|MATCH|L1|"simple"
"    SET|%a|INDEX|L1
"    SET|%b|ITEM|L1
"    INFO|Found 'simple' in L1||||"Index = "|%a|"   Item = "|%b|"(this is the SUB procedure)"
"  END
"  EXIT
"
"CLOSE

:RunScript
  if @file(script.mac)
    LIST LOADFILE, 9, script.mac
  end 
  if @not(@greater(@count(9), 0))
    WARN No valid script file.@tab()@cr()@cr()Aborting...
    EXIT 
  end 
  %%rsx = 0
  REPEAT 
    if @equal(@substr(@item(9,%%rsx), 1), ":")@equal(@substr(@item(9,%%rsx), 1, 3), "rem")@not(@item(9,%%rsx))
      rem -- Skip this line if it's a label, remark, or blank --
    else 
      PARSE "%%command;%%pr1;%%pr2;%%pr3;%%pr4;%%pr5;%%pr6;%%pr7;%%pr8;%%pr9;%%pr10;%%pr11;%%pr12", @item(9,%%rsx)
      GOSUB %%command
    end 
    %%rsx = @succ(%%rsx)
  UNTIL @equal(%%rsx, @count(9))
  exit 

:CLOSE
  STOP 

:TITLE
  TITLE %%pr1
  exit 

:DIALOG
  if @equal(%%pr1, "CREATE")
    DIALOG CREATE,%%pr2,%%pr3,%%pr4,%%pr5,%%pr6,%%pr7,%%pr8,%%pr9,%%pr10,%%pr11,%%pr12
  end 
  if @equal(%%pr1, "ADD")
    DIALOG ADD,%%pr2,%%pr3,%%pr4,%%pr5,%%pr6,%%pr7,%%pr8,%%pr9,%%pr10,%%pr11,%%pr12
  end 
  if @equal(%%pr1, "SHOW")
    if %%pr2
      DIALOG SHOW,%%pr2
    else 
      DIALOG SHOW
    end 
  end 
  if @equal(%%pr1, "HIDE")
    if %%pr2
      DIALOG HIDE,%%pr2
    else 
      DIALOG HIDE
    end 
  end 
  if @equal(%%pr1, "SETPOS")
    GOSUB STR2NUM
    DIALOG SETPOS,%%pr2,%%pr3,%%pr4,%%pr5,%%pr6
  end 
  if @equal(%%pr1, "SET")
    GOSUB STR2NUM
    DIALOG SET,%%pr2,%%pr3%%pr4%%pr5%%pr6%%pr7%%pr8%%pr9%%pr10%%pr11%%pr12
  end 
  if @equal(%%pr1, "CLEAR")
    DIALOG CLEAR,%%pr2
  end 
  exit 

:LIST
  if @equal(%%pr1, "CREATE")
    if %%pr3
      LIST CREATE,%%pr2,%%pr3
    else 
      LIST CREATE,%%pr2
    end 
  end 
  if @equal(%%pr1, "SEEK")
    LIST SEEK,%%pr2,%%pr3
  end 
  if @equal(%%pr1, "CLEAR")
    LIST CLEAR,%%pr2
  end 
  if @equal(%%pr1, "CLOSE")
    LIST CLOSE,%%pr2
  end 
  if @equal(%%pr1, "LOADFILE")
    LIST LOADFILE,%%pr2,%%pr3
  end 
  if @equal(%%pr1, "SAVEFILE")
    LIST SAVEFILE,%%pr2,%%pr3
  end 
  if @equal(%%pr1, "FILELIST")
    if %%pr4
      LIST FILELIST,%%pr2,%%pr3,%%pr4
    else 
      if %%pr3
        LIST FILELIST,%%pr2,%%pr3
      else 
        LIST FILELIST,%%pr2
      end 
    end 
  end 
  if @equal(%%pr1, "WINLIST")
    if %%pr3
      LIST WINLIST,%%pr2,%%pr3
    else 
      LIST WINLIST,%%pr2
    end 
  end 
  if @equal(%%pr1, "DROPFILES")
    LIST  DROPFILES,%%pr2
  end 
  if @equal(%%pr1, "REGKEYS")
    LIST  REGKEYS,%%pr2,%%pr3,%%pr4
  end 
  if @equal(%%pr1, "REGVALS")
    LIST  REGVALS,%%pr2,%%pr3,%%pr4
  end 
  if @equal(%%pr1, "ADD")
    LIST ADD,%%pr2,%%pr3%%pr4%%pr5%%pr6%%pr7%%pr8%%pr9%%pr10%%pr11%%pr12
  end 
  if @equal(%%pr1, "PUT")
    LIST PUT,%%pr2,%%pr3%%pr4%%pr5%%pr6%%pr7%%pr8%%pr9%%pr10%%pr11%%pr12
  end 
  if @equal(%%pr1, "WRITE")
    LIST WRITE,%%pr2,%%pr3%%pr4%%pr5%%pr6%%pr7%%pr8%%pr9%%pr10%%pr11%%pr12
  end 
  if @equal(%%pr1, "ASSIGN")
    LIST ASSIGN,%%pr2,%%pr3
  end 
  if @equal(%%pr1, "COPY")
    LIST COPY,%%pr2
  end 
  if @equal(%%pr1, "PASTE")
    LIST PASTE,%%pr2
  end 
  if @equal(%%pr1, "INSERT")
    LIST INSERT,%%pr2,%%pr3%%pr4%%pr5%%pr6%%pr7%%pr8%%pr9%%pr10%%pr11%%pr12
  end 
  if @equal(%%pr1, "DELETE")
    LIST DELETE,%%pr2
  end 
  exit 

:GOTO
  if @equal(%%pr1, "EVENT")
    %%pr1 = %%event
  else 
    %%pr1 = ":"%%pr1
  end 
  LIST SEEK, 9, 0
  if @match(9, %%pr1)
    %%rsx = @index(9)
  else 
    INFO Error - Label %%pr1 not found...
    STOP 
  end 
  exit 

:GOSUB
  %%gosubx = %%rsx
  LIST SEEK, 9, 0
  if @match(9, ":"%%pr1)
    %%rsx = @index(9)
  else 
    INFO Error - Label %%pr1 not found...
    STOP 
  end 
  REPEAT 
    %%rsx = @succ(%%rsx)
    if @equal(@substr(@item(9,%%rsx), 1), ":")@equal(@substr(@item(9,%%rsx), 1, 3), "rem")@not(@item(9,%%rsx))
      rem -- Skip this line if it's a label, remark, or blank --
    else 
      PARSE "%%command;%%pr1;%%pr2;%%pr3;%%pr4;%%pr5;%%pr6;%%pr7;%%pr8;%%pr9;%%pr10;%%pr11;%%pr12", @item(9,%%rsx)
      if @not(@equal(%%command, "EXIT"))
        GOSUB %%command
      end 
    end 
  UNTIL @equal(%%command, "EXIT")
  %%rsx = %%gosubx
  exit 

:IF
  GOSUB STR2NUM
  %%true = ""
  if @equal(%%pr1, "EQUAL")
    if @equal(%%pr2,%%pr3)
      %%true = 1
    end 
  end 
  if @equal(%%pr1, "GREATER")
    if @greater(%%pr2,%%pr3)
      %%true = 1
    end 
  end 
  if @equal(%%pr1, "MATCH")
    if @match(%%pr2,%%pr3)
      %%true = 1
    end 
  end 
  REPEAT 
    %%rsx = @succ(%%rsx)
    if @equal(@substr(@item(9,%%rsx), 1), ":")@equal(@substr(@item(9,%%rsx), 1, 3), "rem")@not(@item(9,%%rsx))
      rem -- Skip this line if it's a label, remark, or blank --
    else 
      PARSE "%%command;%%pr1;%%pr2;%%pr3;%%pr4;%%pr5;%%pr6;%%pr7;%%pr8;%%pr9;%%pr10;%%pr11;%%pr12", @item(9,%%rsx)
      if %%true
        GOSUB %%command
      end 
    end 
  UNTIL @equal(%%command, "END")@equal(%%command, "ELSE")
  if @equal(%%command, "ELSE")
    REPEAT 
      %%rsx = @succ(%%rsx)
      if @equal(@substr(@item(9,%%rsx), 1), ":")@equal(@substr(@item(9,%%rsx), 1, 3), "rem")@not(@item(9,%%rsx))
        rem -- Skip this line if it's a label, remark, or blank --
      else 
        PARSE "%%command;%%pr1;%%pr2;%%pr3;%%pr4;%%pr5;%%pr6;%%pr7;%%pr8;%%pr9;%%pr10;%%pr11;%%pr12", @item(9,%%rsx)
        if @not(%%true)
          GOSUB %%command
        end 
      end 
    UNTIL @equal(%%command, "END")
  end 
  exit 
:ELSE
  exit 
:END
  exit 

:INFO
  GOSUB STR2NUM
  INFO %%pr1%%pr2%%pr3%%pr4@cr()@cr()%%pr5%%pr6%%pr7%%pr8@cr()@cr()%%pr9%%pr10%%pr11%%pr12
  exit 

:WAIT
  if %%pr2
    WAIT %%pr1, %%pr2
  else 
    WAIT %%pr1
  end 
  if @equal(%%pr1, EVENT)
    %%event = :@event()
  end 
  if @equal(%%event, ":CLOSE")
    STOP 
  end 
  exit 

:SET
  %%var = %%pr1
  GOSUB STR2NUM
  rem -- Check for functions in parameter 2 --
  if @equal(%%pr2, "DLGTEXT")
    %%pr2 = @dlgtext(%%pr3)
  end 
  if @equal(%%pr2, "ITEM")
    if %%pr4
      %%pr2 = @item(%%pr3,%%pr4)
    else 
      %%pr2 = @item(%%pr3)
    end 
  end 
  if @equal(%%pr2, "INDEX")
    %%pr2 = @index(%%pr3)
  end 
  if @equal(%%pr2,"SUM")@equal(%%pr2,"DIFF")@equal(%%pr2,"PROD")@equal(%%pr2,"DIV")
    GOSUB LoadIntFuncs
  end 
  if @equal(%%pr2,"FADD")@equal(%%pr2,"FSUB")@equal(%%pr2,"FMUL")@equal(%%pr2,"FDIV")
    GOSUB LoadFloatFuncs
  end 
  rem -- Store variable name and value in list 7 --
  if @greater(@count(7), 0)
    LIST SEEK, 7, 0
  end 
  if @match(7, %%var)
    LIST PUT, 7, %%var|%%pr2
  else 
    LIST ADD, 7, %%var|%%pr2
  end 
  if @equal(@substr(%%var, 1, 2), "%%")
    goto @substr(%%var, 3, @len(%%var))
  else 
    goto @substr(%%var, 2)
  end 
  :a 
  %a = %%pr2
  exit 
  :b 
  %b = %%pr2
  exit 
  :c 
  %c = %%pr2
  exit 
  :aa 
  %%aa = %%pr2
  exit 
  :bb 
  %%bb = %%pr2
  exit 
  :cc 
  %%cc = %%pr2
  exit 

:STR2NUM
  rem -- If %%pr? is a var, get value from list 7 --
  if @greater(@count(7), 0)
    LIST SEEK, 7, 0
    if @match(7, %%pr1)
      PARSE ";%%pr1", @item(7)
    end 
    LIST SEEK, 7, 0
    if @match(7, %%pr2)
      PARSE ";%%pr2", @item(7)
    end 
    LIST SEEK, 7, 0
    if @match(7, %%pr3)
      PARSE ";%%pr3", @item(7)
    end 
    LIST SEEK, 7, 0
    if @match(7, %%pr4)
      PARSE ";%%pr4", @item(7)
    end 
    LIST SEEK, 7, 0
    if @match(7, %%pr5)
      PARSE ";%%pr5", @item(7)
    end 
    LIST SEEK, 7, 0
    if @match(7, %%pr6)
      PARSE ";%%pr6", @item(7)
    end 
    LIST SEEK, 7, 0
    if @match(7, %%pr7)
      PARSE ";%%pr7", @item(7)
    end 
    LIST SEEK, 7, 0
    if @match(7, %%pr8)
      PARSE ";%%pr8", @item(7)
    end 
    LIST SEEK, 7, 0
    if @match(7, %%pr9)
      PARSE ";%%pr9", @item(7)
    end 
    LIST SEEK, 7, 0
    if @match(7, %%pr10)
      PARSE ";%%pr10", @item(7)
    end 
    LIST SEEK, 7, 0
    if @match(7, %%pr11)
      PARSE ";%%pr11", @item(7)
    end 
    LIST SEEK, 7, 0
    if @match(7, %%pr12)
      PARSE ";%%pr12", @item(7)
    end 
  end 
  exit 

:LoadIntFuncs
  LIST CLEAR, 8
  LIST ADD, 8, sum|@sum(%%pr3,%%pr4)
  LIST ADD, 8, diff|@diff(%%pr3,%%pr4)
  LIST ADD, 8, prod|@prod(%%pr3,%%pr4)
  rem -- Can't divide by zero --
  if @not(@equal(%%pr4, 0))
    LIST ADD, 8, div|@div(%%pr3,%%pr4)
  else 
    %%pr2 = "Can't divide by zero"
  end 
  LIST SEEK, 8, 0
  if @match(8, %%pr2)
    PARSE ";%%pr2", @item(8)
  end 
  exit 

:LoadFloatFuncs
  LIST CLEAR, 8
  LIST ADD, 8, fadd|@fadd(%%pr3,%%pr4)
  LIST ADD, 8, fsub|@fsub(%%pr3,%%pr4)
  LIST ADD, 8, fmul|@fmul(%%pr3,%%pr4)
  rem -- Can't divide by zero --
  if @not(@equal(%%pr4, 0))
    LIST ADD, 8, fdiv|@fdiv(%%pr3,%%pr4)
  else 
    %%pr2 = "Can't divide by zero"
  end 
  LIST SEEK, 8, 0
  if @match(8, %%pr2)
    PARSE ";%%pr2", @item(8)
  end 
  exit 
