  rem **********************************************************************
  rem * SOURCE CODE IS NOT TO BE USED FOR COMMERCIAL OR SHAREWARE PURPOSES *
  rem * AS THAT WOULD BE IN CONFLICT WITH THE LICENSE AGREEMENT OF VISUAL  *
  rem * DIALOGSCRIPT. IF YOU DISAGREE I'LL LEAVE IT UP TO YOU. IT'S NOT ME *
  rem * WHO'S TRYING TO PUT THIS LIMIT.                                    *
  rem **********************************************************************

  rem Scripter V1.01
  rem By Tommy Sools

  rem changes:
  rem   V1.01:
  rem     - surrounded a few percent characters with double quotes
  rem   V1.0:
  rem     - initial version.

  rem main limits (compared with VDS itself):
  rem   - it's impossible to use @CHR(1), in addition to the
  rem     impossibility to use @CHR(0) in VDS.
  rem   - 64 kB transfer buffer limit on any DLL call.
  rem   - 64 kB transfer buffer limit on LIST command and related functions.

  rem main differences (compared with VDS itself):
  rem   - command and function names need to be explicit, for example
  rem     instead of @WIN() you'll have to use @WINEXISTS(), so
  rem     abbreviations won't work.
  rem   - %1 up to %9 return information about %2 up to '%10',
  rem     as %1 is used to identify the script filename.

  rem working VDS examples:
  rem calc.dsc
  rem cursor.dsc
  rem ddetest.dsc
  rem dlgtest.dsc
  rem dragdrop.dsc
  rem infotest.dsc
  rem mmplay.dsc
  rem   you'll have to fix the bugs first:
  rem     - remove the final bracket at line 44.
  rem     - surround the final percent character at line 89 with double quotes.
  rem     -     "     "    "      "        "     "   "   97  "     "      "   .
  rem     - replace "ELSE" on line 102 with "if @not(@numeric(%R))".
  rem  then to improve the script do the following:
  rem     - replace "if @not(@equal(%R,%P))" on line 98 with "if @not(@equal(@mci(status media mode),stopped))".
  rem     - then remove line 92: "%p = %R".
  rem multidlg.dsc
  rem paramtst.dsc
  rem   works, but %1 up to %9 return information about %2 up to '%10',
  rem   as %1 is used to identify the script filename.
  rem propties.dsc
  rem resiztst.dsc
  rem sktest.dsc
  rem   it must be noted that sktest.dsc is often troubling, but this is the
  rem   case, even if loaded in VDS directly, and therefore isn't to blame to
  rem   Scripter.
  rem taskicon.dsc
  rem trackbars.dsc
  rem verinfo.dsc
  rem wizard.dsc

  rem also working are:
  rem   Dagur Páll Ammendrup:
  rem     armageddon.dsc
  rem   Garrett R. Hylltun:
  rem     gt-hotspotexample.dsc
  rem     gt-movenotitle.dsc
  rem     gt-notepad.dsc
  rem   Julian Moss:
  rem     notepad.dsc
  rem   Mac:
  rem     cpl.dsc
  rem     move.dsc
  rem     move_elements.dsc
  rem     numconv.dsc
  rem     rolodex.dsc
  rem     ssbounce.dsc
  rem       only tested if ran as a script rather than screensaver.
  rem     tempconv.dsc
  rem   Mike Cherry:
  rem     vds2asm.dsc
  rem     vds2cpp.dsc
  rem   Moke:
  rem     vdscrypt.dsc
  rem       this script works, although the script will act weirdly as
  rem       it misuses GOSUB and GOTO commands (it acts weirdly if running in
  rem       VDS itself too).
  rem   Tommy Sools:
  rem     barcode.dsc
  rem     clock-bar.dsc
  rem     dlgedit.dsc
  rem     dsc2html.dsc
  rem       works, but extremely slow
  rem     softice.dsc
  rem     vdsformt.dsc
  rem       works, but extremely slow
  rem     vdsirc.dsc

  rem untested are:
  rem   Garrett Hylltun:
  rem     gt-cgiguestbook.dsc
  rem     gt-getip.dsc
  rem       Windows 9x is required
  rem     gt-getsystemcolors.dsc
  rem     gt-getsystemsizes.dsc
  rem     htmstrip.dsc
  rem   Henrik Skov
  rem     msagent.dsc
  rem       requires Microsoft Agent

  %%null            = @chr(1)
  %%vdsrun          =
  %%vdslist         =

  %%listNormal      = 12

  %%listList        = 3
  %%listGosub       = 4
  %%listRepeat      = 5
  %%listDLL         = 6
  %%listVarName     = 7
  %%listVarContents = 8
  %%listScript      = 9

  %%scriptFile = %1
  shift

  if %%scriptFile
    if @file(%%scriptFile)
      list create,%%listScript
      list loadfile,%%listScript,%%scriptFile
      directory change,@path(%%scriptFile)

      gosub startScript

      list close,%%listScript
    else
      warn Script file doesn't exist!
    end
  else
    dialog create,Dummy,,,,,CLASS Dummy

    rem let dialog steal the focus
    window activate,#Dummy

    directory change,@regread(CURUSER,Software\SADE\VDS\3.5,Path)\Examples
    %A = @filedlg("Script Files (*.dsc)|*.dsc",Select VDS script file)
    if %A
      %B = @input(Enter command line parameters:)
      if @ok()
        run @shortname(@path(%0)scripter.exe) @chr(34)%A@chr(34) %B
      end
    end
  end

  exit
:startScript
  if @zero(@count(%%listScript))
    exit
  end
  %%running = 1

  list create,%%listList
  list create,%%listGosub
  list create,%%listDLL
  list create,%%listVarName
  list create,%%listVarContents
  list create,%%listRepeat

  option fieldsep,|
  %%fieldSep          = |
  %n                  = 0
  %%errorCode         = 0
  %%errorTrap         =
  %%errorLine         =
  %%errorError        =
  %%errorScripterLine =
  %%noAssignments     =
  %%loadText          =
  %%ok                = 1
  rem gosub LIB_Init
  gosub nextLine
  exit
:stopScript
  if %%running
    list close,%%listRepeat
    list close,%%listVarContents
    list close,%%listVarName
    list close,%%listDLL
    list close,%%listGosub
    list close,%%listList
    %%running =
    rem gosub LIB_Finish
  end
  exit
:nextLine
  %%execLine = @item(%%listScript,%n)
  gosub execLine
  if @not(%%running)
    exit
  end
  if @not(@zero(%%errorCode))
    if %%errorTrap
      %%errorLine         = @succ(%n)
      %%errorScripterLine = @succ(@error(N))
      %%errorError        = %%errorCode
      %%errorCode         = 0
      if @not(@equal(%%errorTrap,ignore))
        %%findLabel         = %%errorTrap
        gosub findLabel
        if %%findLabel
          rem clear the gosub list
          rem list clear,%%listGosub
        else
          warn Untrappable error 12 at line @succ(%n):@cr()Invalid errortrapping label @chr(34)%%errorTrap@chr(34)!
          gosub stopScript
          exit
        end
      end
    else
      warn Fatal error %%errorCode at line @succ(%n)!@cr()"("Scripter line @succ(@error(N))")"
      gosub stopScript
      exit
    end
  end
  %n = @succ(%n)
  if @greater(%n,@pred(@count(%%listScript)))
    exit
  end
  if %%running
    goto nextLine
  end
  exit
:execLine
  %%execLine = @trim(%%execLine)
  if @not(%%execLine)@equal(@upper(@substr(%%execLine,1,3)),REM)@equal(@substr(%%execLine,1,1),:)@equal(@substr(%%execLine,1,1),')
    exit
  else
    if @equal(@substr(%%execLine,1,1),@chr(34))
      if %%loadText
        rem for lists 3 up to (infinite), the VDSLIST DLL is required
        if @both(@numeric(%%loadText),@greater(1,@pos(@substr(%%loadText,1,1),%%listNormal)))
          if @not(%%vdslist)
            external vdslist.dll
            %%vdslist = 1
          end
          lst add,%%loadText,@strdel(%%execLine,1,1)
        else
          list add,%%loadText,@strdel(%%execLine,1,1)
        end
      else
        %%errorCode = 1
      end
      exit
    else
      %%doubleQuote2Null = %%execLine
      gosub doubleQuote2Null
      %%execLine = %%doubleQuote2Null
      %%assignment =
      if @not(%%noAssignments)
        if @equal(@substr(%%execLine,1,1),"%")
          %%assignment = 1
          %%assignmentLongvar =
          %%execLine = @strdel(%%execLine,1,1)
          if @equal(@substr(%%execLine,1,1),"%")
            %%assignmentLongvar = 1
            %%execLine = @strdel(%%execLine,1,1)
          end
        end
      end
    end
  end
  %%parseVariables = %%execLine
  gosub parseVariables
  %%execLine = %%parseVariables
  if @not(@zero(%%errorcode))
    exit
  end
  %%parseFunctions = %%execLine
  gosub parseFunctions
  %%execLine = %%parseFunctions
  if @not(@zero(%%errorcode))
    exit
  end
  %%parseCommand = %%execLine
  gosub parseCommand
  exit
:parseFunctions
  %%inQuote =
  repeat
    %%found =
    %%bracket2 = 1
    %%break =
    %i = @pred(%%bracket2)
    repeat
      %i = @succ(%i)
      if @equal(@substr(%%parseFunctions,%i,%i),%%null)
        %%inQuote = @not(%%inQuote)
      else
        if @both(@equal(@substr(%%parseFunctions,%i,%i),")"),@not(%%inQuote))
          %%found = 1
          %%break = 1
        end
      end
    until @greater(%i,@pred(@len(%%parseFunctions)))%%break
    if @not(%%found)
      exit
    end
    %%bracket2 = %i

    %%found =
    %%bracket1 = %%bracket2
    %%break =
    %i = @succ(%%bracket1)
    repeat
      %i = @pred(%i)
      if @equal(@substr(%%parseFunctions,%i,%i),%%null)
        %%inQuote = @not(%%inQuote)
      else
        if @both(@equal(@substr(%%parseFunctions,%i,%i),"("),@not(%%inQuote))
          %%found = 1
          %%break = 1
        end
      end
    until @greater(2,%i)%%break
    if @not(%%found)
      %%errorCode = 5
      exit
    end
    %%bracket1 = %i

    %%found =
    %%at = %%bracket1
    %%break =
    %i = @succ(%%at)
    repeat
      %i = @pred(%i)
      if @equal(@substr(%%parseFunctions,%i,%i),%%null)
        %%inQuote = @not(%%inQuote)
      else
        if @both(@equal(@substr(%%parseFunctions,%i,%i),"@"),@not(%%inQuote))
          %%found = 1
          %%break = 1
        end
      end
    until @greater(2,@pred(%i))%%break
    if @not(%%found)
      %%errorCode = 5
      exit
    end
    %%at = %i
    
    %%execFunction = @substr(%%parseFunctions,@succ(%%at),@pred(%%bracket1))
    %%params = @substr(%%parseFunctions,@succ(%%bracket1),@pred(%%bracket2))
    
    rem remove the null characters
    if @not(@zero(@pos(%%null,%%execFunction)))
      repeat
        %%pos = @pos(%%null,%%execFunction)
        %%execFunction = @strdel(%%execFunction,%%pos,%%pos)
      until @zero(@pos(%%null,%%execFunction))
    end

    %%parseFunctions = @strdel(%%parseFunctions,%%at,%%bracket2)

    REM :execFunction
    %%LIB_Function = %%execFunction
    option errortrap,LIB_Error
    gosub LIB_Function
    option errortrap,
    %%ok = @ok()
    %%execFunction = %%LIB_Function
    REM END OF :execFunction

    %%parseFunctions = @strins(%%parseFunctions,%%at,%%null%%execFunction%%null)
  until @not(@zero(%%errorCode))
  exit
:parseCommand
  %%space =
  %%inQuote =
  %i = 0
  repeat
    %i = @succ(%i)
    if @equal(@substr(%%parseCommand,%i,%i),%%null)
      %%inQuote = @not(%%inQuote)
    else
      if @both(@equal(@substr(%%parseCommand,%i,%i)," "),@not(%%inQuote))
        %%space = %i
      end
    end
  until %%space@greater(@pred(%i),@len(%%parseCommand))

  if %%space
    if @equal(%%space,1)
      %%execCommand =
    else
      %%execCommand = @substr(%%parseCommand,1,@pred(%%space))
    end
    %%params = @substr(%%parseCommand,@succ(%%space),@len(%%parseCommand))
  else
    %%execCommand = %%parseCommand
    %%params =
  end
  
  rem remove the null characters
  if @not(@zero(@pos(%%null,%%execCommand)))
    repeat
      %%pos = @pos(%%null,%%execCommand)
      %%execCommand = @strdel(%%execCommand,%%pos,%%pos)
    until @zero(@pos(%%null,%%execCommand))
  end

  REM :execCommand
  %%LIB_Command = %%execCommand
  if %%assignment
    %%setVariable = %%LIB_Command
    %%trim = %%params
    gosub trim
    if @equal(@substr(%%trim,1,1),=)
      %%trim = @strdel(%%trim,1,1)
      gosub trim
      %%params = %%trim
    end

    rem remove the null characters
    if @not(@zero(@pos(%%null,%%params)))
      repeat
        %%pos = @pos(%%null,%%params)
        %%params = @strdel(%%params,%%pos,%%pos)
      until @zero(@pos(%%null,%%params))
    end

    %%varContents = %%params
    gosub setVariable
  else
    option errortrap,LIB_Error
    gosub LIB_Command
    option errortrap,
    %%ok = @ok()
  end
  REM END OF :execCommand

  exit
:doubleQuote2Null
  %i = 0
  repeat
    %i = @succ(%i)
    if @equal(@substr(%%doubleQuote2Null,%i,%i),@chr(34))
      rem if @equal(@substr(%%doubleQuote2Null,@succ(%i),@succ(%i)),@chr(34))
      rem   %%doubleQuote2Null = @strdel(%i,%i)
      rem else
      %%doubleQuote2Null = @strins(@strdel(%%doubleQuote2Null,%i,%i),%i,%%null)
      rem end
    end
  until @greater(@pred(%i),@len(%%doubleQuote2Null))
  exit
:parseVariables
  %%inQuote =
  %i = 1
  if @not(@zero(@len(%%parseVariables)))
    repeat
      if @equal(@substr(%%parseVariables,%i,%i),%%null)
        %%inQuote = @not(%%inQuote)
      else
        if @both(@equal(@substr(%%parseVariables,%i,%i),"%"),@not(%%inQuote))
          if @equal(@substr(%%parseVariables,@succ(%i),@succ(%i)),"%")
            rem long variable name
            %%var1 = @sum(%i,2)
            %%var2 = %%var1
            if @greater(@pred(%%var1),@len(%%parseVariables))
              %%errorCode = 7
              exit
            end
            if @not(@zero(@pos(@substr(%%parseVariables,%%var2,%%var2),abcdefghijklmnopqrstuvwxyz0123456789_))@greater(@pred(%%var2),@len(%%parseVariables)))
              repeat
                %%var2 = @succ(%%var2)
              until @zero(@pos(@substr(%%parseVariables,%%var2,%%var2),abcdefghijklmnopqrstuvwxyz0123456789_))@greater(@pred(%%var2),@len(%%parseVariables))
              if @not(@greater(@pred(%%var2),@len(%%parseVariables)))
                %%var2 = @pred(%%var2)
              end
            end
            %%execVariable = @substr(%%parseVariables,%%var1,%%var2)
            %%parseVariables = @strdel(%%parseVariables,%i,%%var2)
          else
            rem short variable name
            if @greater(@succ(%i),@len(%%parseVariables))
              %%errorCode = 7
              exit
            end
            %%execVariable = @substr(%%parseVariables,@succ(%i),@succ(%i))
            %%parseVariables = @strdel(%%parseVariables,%i,@succ(%i))
          end
          gosub execVariable
          %%parseVariables = @strins(%%parseVariables,%i,%%null%%execVariable%%null)
          %i = @sum(%i,@len(%%execVariable),1)
        end
      end
      %i = @succ(%i)
    until @greater(%i,@len(%%parseVariables))
  end
  exit
:nextParam
  if @greater(@len(%%params),0)
    %%inQuote =
    %%comma = 0
    %%break =
    %i = 0
    repeat
      %i = @succ(%i)
      if @equal(@substr(%%params,%i,%i),%%null)
        %%inQuote = @not(%%inQuote)
      else
        if @both(@equal(@substr(%%params,%i,%i),","),@not(%%inquote))
          %%comma = %i
          %%break = 1
        end
      end
    until @greater(@pred(%i),@len(%%params))%%break
    if @zero(%%comma)
      %%nextParam = %%params
      %%params =
    else
      if @equal(%%comma,1)
        %%nextParam =
        %%params = @strdel(%%params,1,1)
      else
        %%nextParam = @substr(%%params,1,@pred(%%comma))
        %%params = @substr(%%params,@succ(%%comma),@len(%%params))
      end
    end
  else
    %%nextParam =
  end

  %%trim = %%nextParam
  gosub trim
  %%nextParam = %%trim

  rem remove the null characters
  if @not(@zero(@pos(%%null,%%nextParam)))
    repeat
      %%pos = @pos(%%null,%%nextParam)
      %%nextParam = @strdel(%%nextParam,%%pos,%%pos)
    until @zero(@pos(%%null,%%nextParam))
  end
  exit
:setVariable
  if @equal(%%setVariable,0)
    %%errorCode = 5
  else
    if @equal(%%setVariable,1)
      %1 = %%varContents
    else
      if @equal(%%setVariable,2)
        %2 = %%varContents
      else
        if @equal(%%setVariable,3)
          %3 = %%varContents
        else
          if @equal(%%setVariable,4)
            %4 = %%varContents
          else
            if @equal(%%setVariable,5)
              %5 = %%varContents
            else
              if @equal(%%setVariable,6)
                %6 = %%varContents
              else
                if @equal(%%setVariable,7)
                  %7 = %%varContents
                else
                  if @equal(%%setVariable,8)
                    %8 = %%varContents
                  else
                    if @equal(%%setVariable,9)
                      %9 = %%varContents
                    else
                      %%varNumber =
                      if @not(@zero(@count(%%listVarName)))
                        list seek,%%listVarName,0
                      end
                      repeat
                        %x = @match(%%listVarName,%%setVariable)
                        if %x
                          if @equal(@item(%%listVarName),%%setVariable)
                            %%varNumber = @index(%%listVarName)
                          end
                        end
                        if @greater(@sum(@index(%%listVarName),2),@count(%%listVarName))
                          %x =
                        else
                          list seek,%%listVarName,@succ(@index(%%listVarName))
                        end
                      until %%varNumber@not(%x)
                      if %%varNumber
                        list seek,%%listVarContents,%%varNumber
                        list put,%%listVarContents,%%varContents
                      else
                        list add,%%listVarName,%%setVariable
                        list add,%%listVarContents,%%varContents
                      end
                    end
                  end
                end
              end
            end
          end
        end
      end
    end
  end
  exit
:execVariable
  if @equal(%%execVariable,0)
    %%execVariable = %%scriptFile
  else
    if @equal(%%execVariable,1)
      %%execVariable = %1
    else
      if @equal(%%execVariable,2)
        %%execVariable = %2
      else
        if @equal(%%execVariable,3)
          %%execVariable = %3
        else
          if @equal(%%execVariable,4)
            %%execVariable = %4
          else
            if @equal(%%execVariable,5)
              %%execVariable = %5
            else
              if @equal(%%execVariable,6)
                %%execVariable = %6
              else
                if @equal(%%execVariable,7)
                  %%execVariable = %7
                else
                  if @equal(%%execVariable,8)
                    %%execVariable = %8
                  else
                    if @equal(%%execVariable,9)
                      %%execVariable = %9
                    else
                      %%varNumber =
                      if @not(@zero(@count(%%listVarName)))
                        list seek,%%listVarName,0
                      end
                      repeat
                        %x = @match(%%listVarName,%%execVariable)
                        if %x
                          if @equal(@item(%%listVarName),%%execVariable)
                            %%varNumber = @index(%%listVarName)
                          end
                        end
                        if @greater(@sum(@index(%%listVarName),2),@count(%%listVarName))
                          %x =
                        else
                          list seek,%%listVarName,@succ(@index(%%listVarName))
                        end
                      until %%varNumber@not(%x)
                      if %%varNumber
                        list seek,%%listVarContents,%%varNumber
                        %%execVariable = @item(%%listVarContents)
                      else
                        %%execVariable =
                      end
                    end
                  end
                end
              end
            end
          end
        end
      end
    end
  end
  exit
:trim
  if @greater(@pos(@substr(%%trim,1,1)," "@tab()),0)
    repeat
      %%trim = @strdel(%%trim,1,1)
    until @not(@greater(@pos(@substr(%%trim,1,1)," "@tab()),0))
  end
  if @greater(@pos(@substr(%%trim,@len(%%trim),@len(%%trim))," "@tab()),0)
    repeat
      %%trim = @strdel(%%trim,@len(%%trim),@len(%%trim))
    until @not(@greater(@pos(@substr(%%trim,@len(%%trim),@len(%%trim))," "@tab()),0))
  end
  exit

:findLabel
  %%label =
  list seek,%%listScript,0
  repeat
    %x = @match(%%listScript,:%%findLabel)
    if %x
      if @equal(@item(%%listScript),:%%findLabel)
        %%label = @index(%%listScript)
      end
    end
    if @greater(@sum(@index(%%listScript),2),@count(%%listScript))
      %x =
    else
      list seek,%%listScript,@succ(@index(%%listScript))
    end
  until %%label@not(%x)
  if %%label
    %n = %%label
    %%findLabel = 1
  else
    %%findLabel =
  end
  exit
:gotoLine
  %%gotoLine = @diff(%%gotoLine,2)
  if @not(@greater(0,%%gotoLine)@greater(%%gotoLine,@pred(@count(%%listScript))))
    %n = %%gotoLine
    %%gotoLine = 1
  else
    %%gotoLine =
  end
  exit

:LIB_Init
  exit
:LIB_Finish
  exit
:LIB_Command
  if @equal(%%LIB_Command,BEEP)
    gosub nextParam
    beep %%nextParam
    exit
  end
  if @equal(%%LIB_Command,CLIPBOARD)
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    clipboard %%a,%%nextParam
    exit
  end
  if @equal(%%LIB_Command,DDE)
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    %%b = %%nextParam
    gosub nextParam
    dde %%a,%%b,%%nextParam
    exit
  end
  if @equal(%%LIB_Command,DIALOG)
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    %%b = %%nextParam
    gosub nextParam
    %%c = %%nextParam
    gosub nextParam
    %%d = %%nextParam
    gosub nextParam
    %%e = %%nextParam
    gosub nextParam
    %%f = %%nextParam
    gosub nextParam
    %%g = %%nextParam
    gosub nextParam
    %%h = %%nextParam
    gosub nextParam
    %%i = %%nextParam
    gosub nextParam
    %%j = %%nextParam
    gosub nextParam
    %%k = %%nextParam
    gosub nextParam
    %%l = %%nextParam
    gosub nextParam
    %%m = %%nextParam
    gosub nextParam
    %%n = %%nextParam
    gosub nextParam
    %%o = %%nextParam
    gosub nextParam
    %%p = %%nextParam
    gosub nextParam
    %%q = %%nextParam
    gosub nextParam
    %%r = %%nextParam
    gosub nextParam
    %%s = %%nextParam
    gosub nextParam
    %%t = %%nextParam
    gosub nextParam
    %%u = %%nextParam
    gosub nextParam
    %%v = %%nextParam
    gosub nextParam
    %%w = %%nextParam
    gosub nextParam
    %%x = %%nextParam
    gosub nextParam
    %%y = %%nextParam
    gosub nextParam
    %%z = %%nextParam
    gosub nextParam
    dialog %%a,%%b,%%c,%%d,%%e,%%f,%%g,%%h,%%i,%%j,%%k,%%l,%%m,%%n,%%o,%%p,%%q,%%r,%%s,%%t,%%u,%%v,%%w,%%x,%%y,%%z,%%nextParam
    exit
  end
  if @equal(%%LIB_Command,DIRECTORY)
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    %%b = %%nextParam
    gosub nextParam
    directory %%a,%%b,%%nextParam
    exit
  end
  if @equal(%%LIB_Command,ELSE)
    %%ifLevel = 1
    rem the %%ifLevel initially of course is 1 as the IF and ELSE command were 
    rem already reached.
    rem the correct END command will be detected at %%ifLevel == 0.
    repeat
      %n = @succ(%n)
      if @greater(@succ(%n),@count(%%listScript))
        %%errorCode = 9
      else
        %%line = @trim(@item(%%listScript,%n))
        if @equal(@substr(%%line,1,2),IF)
          %%ifLevel = @succ(%%ifLevel)
        end
        if @equal(@substr(%%line,1,3),END)
          %%ifLevel = @pred(%%ifLevel)
        end
      end
    until @both(@zero(%%ifLevel),@equal(@substr(%%line,1,3),END))@greater(%%errorCode,0)
    rem the interpreter will automatically go to the next line to skip the END line after this,
    rem so no increasement of %n is neccesary at this time
    exit
  end
  if @equal(%%LIB_Command,END)
    rem the END command is ignored
    exit
  end
  if @equal(%%LIB_Command,EXIT)
    if @zero(@count(%%listGosub))
      gosub stopScript
    else
      list seek,%%listGosub,@pred(@count(%%listGosub))
      %n = @item(%%listGosub)
      list delete,%%listGosub
    end
    exit
  end
  if @equal(%%LIB_Command,EXITWIN)
    gosub nextParam
    exitwin %%nextParam
    exit
  end
  if @equal(%%LIB_Command,EXTERNAL)
    if @not(%%vdsrun)
      external vdsrun.dll
      if @not(@greater(@strdel(@rundll(version),2,2),16))
        %%errorCode = 1000
        rem VDSRUN DLL 1.7 or higher is required for EXTERNAL
      end
      %%vdsrun = 1
    end
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    list add,%%listDLL,@rundll(load,default,%%a,%%nextParam)
    exit
  end
  if @equal(%%LIB_Command,FILE)
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    %%b = %%nextParam
    gosub nextParam
    %%c = %%nextParam
    gosub nextParam
    %%d = %%nextParam
    gosub nextParam
    file %%a,%%b,%%c,%%d,%%nextParam
    exit
  end
  if @equal(%%LIB_Command,GOSUB)
    gosub nextParam
    %%previousLine = %n
    %%findLabel = %%nextParam
    gosub findLabel
    if %%findlabel
      list add,%%listGosub,%%previousLine
    else
      %%errorCode = 12
    end
    exit
  end
  if @equal(%%LIB_Command,GOTO)
    gosub nextParam
    %%findLabel = %%nextParam
    gosub findLabel
    if @not(%%findLabel)
      %%errorCode = 12
    end
    exit
  end
  if @equal(%%LIB_Command,GOTOL)
    gosub nextParam
    %%gotoLine = %%nextParam
    gosub gotoLine
    exit
  end
  if @equal(%%LIB_Command,IF)
    gosub nextParam
    %%ifLevel = 1
    rem the %%ifLevel initially of course is 1 as the IF command was already
    rem reached.
    rem the correct ELSE command will be detected at %%ifLevel == 1;
    rem the correct END  command will be detected at %%ifLevel == 0.
    if @not(%%nextParam)
      rem search for the appropriate ELSE or END command
      repeat
        %n = @succ(%n)
        if @greater(@succ(%n),@count(%%listScript))
          %%errorCode = 9
        else
          %%line = @trim(@item(%%listScript,%n))
          if @equal(@substr(%%line,1,2),IF)
            %%ifLevel = @succ(%%ifLevel)
          end
          if @equal(@substr(%%line,1,3),END)
            %%ifLevel = @pred(%%ifLevel)
          end
        end
      until @both(@equal(%%ifLevel,1),@equal(@substr(%%line,1,4),ELSE))@both(@zero(%%ifLevel),@equal(@substr(%%line,1,3),END))@greater(%%errorCode,0)
      rem the interpreter will automatically go to the next line to skip the ELSE/END line after this,
      rem so no increasement of %n is neccesary at this time
    end
    exit
  end
  if @equal(%%LIB_Command,INFO)
    gosub nextParam
    if @not(%%nextParam)
      %%nextParam = " "
    end
    info %%nextParam
    exit
  end
  if @equal(%%LIB_Command,INIFILE)
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    %%b = %%nextParam
    gosub nextParam
    %%c = %%nextParam
    gosub nextParam
    inifile %%a,%%b,%%c,%%nextParam
    exit
  end
  if @equal(%%LIB_Command,LINK)
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    %%b = %%nextParam
    gosub nextParam
    %%c = %%nextParam
    gosub nextParam
    %%d = %%nextParam
    gosub nextParam
    %%e = %%nextParam
    gosub nextParam
    %%f = %%nextParam
    gosub nextParam
    link %%a,%%b,%%c,%%d,%%e,%%f,%%nextParam
    exit
  end
  if @equal(%%LIB_Command,LIST)
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    %%b = %%nextParam
    gosub nextParam
    %%c = %%nextParam
    gosub nextParam

    if @equal(%%a,LOADTEXT)
      list clear,%%b
      %%loadText = %%b
      exit
    end
    rem for lists 3 up to (infinite), the VDSLIST DLL is required
    if @both(@numeric(%%b),@greater(1,@pos(@substr(%%b,1,1),%%listNormal)))
      if @not(%%vdslist)
        external vdslist.dll
        %%vdslist = 1
      end
      if @equal(%%a,DROPFILES)
        list dropfiles,2
        lst assign,%%b,@text(2)
        exit
      end
      if @equal(%%a,WINLIST)
        list winlist,2,%%c
        lst assign,%%b,@text(2)
        exit
      end
      if @equal(%%a,FILELIST)
        list filelist,2,%%c,%%nextParam
        lst assign,%%b,@text(2)
        exit
      end
      if @equal(%%a,REGKEYS)
        list regkeys,2,%%c,%%nextParam
        lst assign,%%b,@text(2)
        exit
      end
      if @equal(%%a,REGVALS)
        list regvals,2,%%c,%%nextParam
        lst assign,%%b,@text(2)
        exit
      end
      if @equal(%%a,ASSIGN)
        rem determine whether the list that's to be assigned is a VDS based list
        %%listvds =
        option errortrap,skip
        %%text    = @text(%%c)
        %%listvds = 1
  :skip
        option errortrap,LIB_Error
        if @not(%%listvds)
          if @lst(exists,%%c)
            %%text = @lst(text,%%c)
          else
            %%text = %%c
          end
        end
        lst assign,%%b,%%text
        exit
      end
      lst %%a,%%b,%%c,%%nextParam
      exit
    end
    if @equal(%%a,ASSIGN)
      rem determine whether the list that's to be assigned is a VDS based list
      %%listvds =
      option errortrap,skip2
      %%text    = @text(%%c)
      %%listvds = 1
:skip2
      option errortrap,LIB_Error
      if @not(%%listvds)
        if @not(%%vdslist)
          external vdslist.dll
          %%vdslist = 1
        end
        if @lst(exists,%%c)
          %%text = @lst(text,%%c)
        else
          %%text = %%c
        end
      end
      list assign,%%b,%%text
      exit
    end
    list %%a,%%b,%%c,%%nextParam
    exit
  end
  if @equal(%%LIB_Command,OPTION)
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    if @equal(%%a,NOASSIGNMENTS)
      if %%nextParam
        %%noAssignments = 1
      else
        %%noAssignments =
      end
    else
      if @equal(%%a,FIELDSEP)
        %%fieldSep = %%nextParam
        option fieldsep,%%nextParam
      else
        if @equal(%%a,ERRORTRAP)
          %%errorTrap = %%nextParam
        else
          option %%a,%%nextParam
        end
      end
    end
    exit
  end
  if @equal(%%LIB_Command,PARSE)
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam

    if %%a
      repeat
        if @greater(@pos(";",%%a),0)
          %%pos = @pos(";",%%a)
          if @equal(%%pos,1)
            %%field =
          else
            %%field = @substr(%%a,1,@pred(%%pos))
          end
          %%a = @strdel(%%a,1,%%pos)
        else
          %%field = %%a
          %%a =
        end

        if @equal(@substr(%%field,1,1),"%")
          repeat
            %%field = @strdel(%%field,1,1)
          until @not(@equal(@substr(%%field,1,1),"%"))
          %%setVariable = %%field
        else
          %%setVariable =
        end

        if @greater(@pos(%%fieldSep,%%nextParam),0)
          %%pos = @pos(%%fieldSep,%%nextParam)
          if @equal(%%pos,1)
            %%varContents =
          else
            %%varContents = @substr(%%nextParam,1,@pred(%%pos))
          end
          %%nextParam = @strdel(%%nextParam,1,%%pos)
        else
          %%varContents = %%nextParam
          %%nextParam =
        end

        if %%setVariable
          gosub setVariable
        else
          if %%field
            dialog set,%%field,%%varContents
          end
        end
      until @not(%%a)
    end
    exit
  end
  if @equal(%%LIB_Command,PLAY)
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    play %%a,%%nextParam
    exit
  end
  if @equal(%%LIB_Command,REGISTRY)
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    %%b = %%nextParam
    gosub nextParam
    %%c = %%nextParam
    gosub nextParam
    %%d = %%nextParam
    gosub nextParam
    %%e = %%nextParam
    gosub nextParam
    registry %%a,%%b,%%c,%%d,%%e,%%nextParam
    exit
  end
  rem REM is implemented elsewhere
  if @equal(%%LIB_Command,REPEAT)
    list add,%%listRepeat,%n
    exit
  end
  if @equal(%%LIB_Command,RUN)@equal(%%LIB_Command,RUNH)@equal(%%LIB_Command,RUNM)@equal(%%LIB_Command,RUNZ)
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    %%b = %%nextParam
    gosub nextParam
    %%c = %%nextParam
    gosub nextParam
    if @equal(%%LIB_Command,RUN)
      run %%a,%%b,%%c,%%d,%%nextParam
      exit
    end
    if @equal(%%LIB_Command,RUNH)
      runh %%a,%%b,%%c,%%d,%%nextParam
      exit
    end
    if @equal(%%LIB_Command,RUNM)
      runm %%a,%%b,%%c,%%d,%%nextParam
      exit
    end
    if @equal(%%LIB_Command,RUNZ)
      runz %%a,%%b,%%c,%%d,%%nextParam
      exit
    end
  end
  if @equal(%%LIB_Command,SET)
    gosub nextParam
    %%setVariable = %%nextParam
    gosub nextParam
    %%varContents = %%nextParam
    gosub setVariable
    exit
  end
  if @equal(%%LIB_Command,SHELL)
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    %%b = %%nextParam
    gosub nextParam
    %%c = %%nextParam
    gosub nextParam
    %%d = %%nextParam
    gosub nextParam
    %%e = %%nextParam
    gosub nextParam
    shell %%a,%%b,%%c,%%d,%%e,%%nextParam
    exit
  end
  if @equal(%%LIB_Command,SHIFT)
    shift
    exit
  end
  if @equal(%%LIB_Command,STOP)
    gosub stopScript
    exit
  end
  if @equal(%%LIB_Command,UNTIL)
    gosub nextParam
    list seek,%%listRepeat,@pred(@count(%%listRepeat))
    if %%nextParam
      list delete,%%listRepeat
    else
      %n = @item(%%listRepeat)
    end
    exit
  end
  if @equal(%%LIB_Command,TITLE)
    gosub nextParam
    title %%nextParam
    exit
  end
  if @equal(%%LIB_Command,WAIT)
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    wait %%a,%%nextParam
    exit
  end
  if @equal(%%LIB_Command,WARN)
    gosub nextParam
    if @not(%%nextParam)
      %%nextParam = " "
    end
    warn %%nextParam
    exit
  end
  if @equal(%%LIB_Command,WINDOW)
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    %%b = %%nextParam
    gosub nextParam
    %%c = %%nextParam
    gosub nextParam
    %%d = %%nextParam
    gosub nextParam
    %%e = %%nextParam
    gosub nextParam
    window %%a,%%b,%%c,%%d,%%e,%%nextParam
    exit
  end
  if @equal(%%LIB_Command,WINHELP)
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    winhelp %%a,%%nextParam
    exit
  end

  rem check for external command
  %%external =
  if @not(@zero(@count(%%listDLL)))
    list seek,%%listDLL,0
  end
  repeat
    %x = @match(%%listDLL,%%LIB_Command)
    if %x
      if @equal(@item(%%listDLL),%%LIB_Command)
        %%external = @item(%%listDLL)
      end
    end
    if @greater(@sum(@index(%%listDLL),2),@count(%%listDLL))
      %x =
    else
      list seek,%%listDLL,@succ(@index(%%listDLL))
    end
  until %%external@not(%x)
  if %%external
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    %%b = %%nextParam
    gosub nextParam
    %%c = %%nextParam
    gosub nextParam
    %%d = %%nextParam
    gosub nextParam
    %%e = %%nextParam
    gosub nextParam
    %%f = %%nextParam
    gosub nextParam
    %%g = %%nextParam
    gosub nextParam
    %%h = %%nextParam
    gosub nextParam
    %%i = %%nextParam
    gosub nextParam
    %%j = %%nextParam
    gosub nextParam
    %%k = %%nextParam
    gosub nextParam
    %%l = %%nextParam
    gosub nextParam
    %%m = %%nextParam
    gosub nextParam
    %%n = %%nextParam
    gosub nextParam
    %%o = %%nextParam
    gosub nextParam
    %%p = %%nextParam
    gosub nextParam
    %%q = %%nextParam
    gosub nextParam
    %%r = %%nextParam
    gosub nextParam
    %%s = %%nextParam
    gosub nextParam
    %%t = %%nextParam
    gosub nextParam
    %%u = %%nextParam
    gosub nextParam
    %%v = %%nextParam
    gosub nextParam
    %%w = %%nextParam
    gosub nextParam
    %%x = %%nextParam
    gosub nextParam
    %%y = %%nextParam
    gosub nextParam
    %%z = %%nextParam
    gosub nextParam
    rundll %%external,%%a,%%b,%%c,%%d,%%e,%%f,%%g,%%h,%%i,%%j,%%k,%%l,%%m,%%n,%%o,%%p,%%q,%%r,%%s,%%t,%%u,%%v,%%w,%%x,%%y,%%z,%%nextParam
    exit
  end

  %%errorCode = 1
  exit
:LIB_Function
  if @equal(%%LIB_Function,ALT)
    gosub nextParam
    %%LIB_Function = @alt(%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,ASC)
    gosub nextParam
    %%LIB_Function = @asc(%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,ASK)
    gosub nextParam
    %%LIB_Function = @ask(%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,BOTH)
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    %%LIB_Function = @both(%%a,%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,CHR)
    gosub nextParam
    %%LIB_Function = @chr(%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,CLICK)
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    %%b = %%nextParam
    gosub nextParam
    %%c = %%nextParam
    gosub nextParam
    %%d = %%nextParam
    gosub nextParam
    %%LIB_Function = @click(%%a,%%b,%%c,%%d,%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,COUNT)
    gosub nextParam
    rem for lists 3 up to (infinite), the VDSLIST DLL is required
    if @both(@numeric(%%nextParam),@greater(1,@pos(@substr(%%nextParam,1,1),%%listNormal)))
      if @not(%%vdslist)
        external vdslist.dll
        %%vdslist = 1
      end
      %%LIB_Function = @lst(count,%%nextParam)
    else
      %%LIB_Function = @count(%%nextParam)
    end
    exit
  end
  if @equal(%%LIB_Function,CR)
    %%LIB_Function = @cr()
    exit
  end
  if @equal(%%LIB_Function,CTRL)
    gosub nextParam
    %%LIB_Function = @ctrl(%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,CURDIR)
    gosub nextParam
    %%LIB_Function = @curdir(%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,DATETIME)
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    %%LIB_Function = @datetime(%%a,%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,DDEITEM)
    gosub nextParam
    %%LIB_Function = @ddeitem(%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,DIFF)
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    %%LIB_Function = @diff(%%a,%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,DIRDLG)
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    %%LIB_Function = @dirdlg(%%a,%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,DIV)
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    %%LIB_Function = @div(%%a,%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,DLGPOS)
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    %%LIB_Function = @dlgpos(%%a,%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,DLGTEXT)
    gosub nextParam
    %%LIB_Function = @dlgtext(%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,ENV)
    gosub nextParam
    %%LIB_Function = @env(%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,EQUAL)
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    %%b = %%nextParam
    gosub nextParam
    if %%nextParam
      %%LIB_Function = @equal(%%a,%%b,%%nextParam)
    else
      %%LIB_Function = @equal(%%a,%%b)
    end
    exit
  end
  if @equal(%%LIB_Function,ERROR)
    gosub nextParam
    %%LIB_Function =
    if %%nextParam
      repeat
        if @equal(@substr(%%nextParam,1,1),E)
          %%LIB_Function = %%LIB_Function%%errorError
        else
          if @equal(@substr(%%nextParam,1,1),N)
            %%LIB_Function = %%LIB_Function%%errorLine
          else
            if @equal(@substr(%%nextParam,1,1),S)
              %%LIB_Function = %%LIB_Function%%errorScripterLine
            end
          end
        end
        %%nextParam = @strdel(%%nextParam,1,1)
        if %%nextParam
          %%LIB_Function = %%LIB_Function%%fieldSep
        end
      until @not(%%nextParam)
    end
    exit
  end
  if @equal(%%LIB_Function,ESC)
    %%LIB_Function = @esc()
    exit
  end
  if @equal(%%LIB_Function,EVENT)
    gosub nextParam
    %%LIB_Function = @event(%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,EXT)
    gosub nextParam
    %%LIB_Function = @ext(%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,FADD)
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    %%LIB_Function = @fadd(%%a,%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,FATN)
    gosub nextParam
    %%LIB_Function = @fatn(%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,FCOS)
    gosub nextParam
    %%LIB_Function = @fcos(%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,FDIV)
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    %%LIB_Function = @fdiv(%%a,%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,FEXP)
    gosub nextParam
    %%LIB_Function = @fexp(%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,FILE)
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    %%LIB_Function = @file(%%a,%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,FILEDLG)
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    %%b = %%nextParam
    gosub nextParam
    %%c = %%nextParam
    gosub nextParam
    %%LIB_Function = @filedlg(%%a,%%b,%%c,%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,FLN)
    gosub nextParam
    %%LIB_Function = @fln(%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,FMUL)
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    %%LIB_Function = @fmul(%%a,%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,FORMAT)
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    %%LIB_Function = @format(%%a,%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,FSIN)
    gosub nextParam
    %%LIB_Function = @fsin(%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,FSQT)
    gosub nextParam
    %%LIB_Function = @fsqt(%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,FSUB)
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    %%LIB_Function = @fsub(%%a,%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,GREATER)
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    %%LIB_Function = @greater(%%a,%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,HEX)
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    %%LIB_Function = @hex(%%a,%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,INDEX)
    gosub nextParam
    rem for lists 3 up to (infinite), the VDSLIST DLL is required
    if @both(@numeric(%%nextParam),@greater(1,@pos(@substr(%%nextParam,1,1),%%listNormal)))
      if @not(%%vdslist)
        external vdslist.dll
        %%vdslist = 1
      end
      %%LIB_Function = @lst(index,%%nextParam)
    else
      %%LIB_Function = @index(%%nextParam)
    end
    exit
  end
  if @equal(%%LIB_Function,INIREAD)
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    %%b = %%nextParam
    gosub nextParam
    %%LIB_Function = @iniread(%%a,%%b,%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,INPUT)
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    %%b = %%nextParam
    gosub nextParam
    if %%nextParam
      %%LIB_Function = @input(%%a,%%b,%%nextParam)
    else
      %%LIB_Function = @input(%%a,%%b)
    end
    exit
  end
  if @equal(%%LIB_Function,ITEM)
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    rem for lists 3 up to (infinite), the VDSLIST DLL is required
    if @both(@numeric(%%a),@greater(1,@pos(@substr(%%a,1,1),%%listNormal)))
      if @not(%%vdslist)
        external vdslist.dll
        %%vdslist = 1
      end
      %%LIB_Function = @lst(item,%%a,%%nextParam)
    else
      %%LIB_Function = @item(%%a,%%nextParam)
    end
    exit
  end
  if @equal(%%LIB_Function,KEY)
    gosub nextParam
    %%LIB_Function = @key(%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,LEN)
    gosub nextParam
    %%LIB_Function = @len(%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,LOWER)
    gosub nextParam
    %%LIB_Function = @lower(%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,MATCH)
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    rem for lists 3 up to (infinite), the VDSLIST DLL is required
    if @both(@numeric(%%a),@greater(1,@pos(@substr(%%a,1,1),%%listNormal)))
      if @not(%%vdslist)
        external vdslist.dll
        %%vdslist = 1
      end
      %%LIB_Function = @lst(match,%%a,%%nextParam)
    else
      %%LIB_Function = @match(%%a,%%nextParam)
    end
    exit
  end
  if @equal(%%LIB_Function,MCI)
    gosub nextParam
    %%LIB_Function = @mci(%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,MOD)
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    %%LIB_Function = @mod(%%a,%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,MOUSEPOS)
    gosub nextParam
    %%LIB_Function = @mousepos(%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,MSGBOX)
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    %%b = %%nextParam
    gosub nextParam
    %%LIB_Function = @msgbox(%%a,%%b,%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,NAME)
    gosub nextParam
    %%LIB_Function = @name(%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,NEXT)
    gosub nextParam
    rem for lists 3 up to (infinite), the VDSLIST DLL is required
    if @both(@numeric(%%nextParam),@greater(1,@pos(@substr(%%nextParam,1,1),%%listNormal)))
      if @not(%%vdslist)
        external vdslist.dll
        %%vdslist = 1
      end
      %%LIB_Function = @lst(next,%%nextParam)
    else
      %%LIB_Function = @next(%%nextParam)
    end
    exit
  end
  if @equal(%%LIB_Function,NOT)
    gosub nextParam
    %%LIB_Function = @not(%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,NULL)
    gosub nextParam
    %%LIB_Function = @null(%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,NUMERIC)
    gosub nextParam
    %%LIB_Function = @numeric(%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,OK)
    %%LIB_Function = %%ok
    exit
  end
  if @equal(%%LIB_Function,PATH)
    gosub nextParam
    %%LIB_Function = @path(%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,POS)
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    %%LIB_Function = @pos(%%a,%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,PRED)
    gosub nextParam
    %%LIB_Function = @pred(%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,PROD)
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    %%LIB_Function = @prod(%%a,%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,QUERY)
    gosub nextParam
    %%LIB_Function = @query(%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,REGREAD)
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    %%b = %%nextParam
    gosub nextParam
    %%c = %%nextParam
    gosub nextParam
    %%LIB_Function = @regread(%%a,%%b,%%c,%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,RETCODE)
    %%LIB_Function = @retcode()
    exit
  end
  if @equal(%%LIB_Function,SENDMSG)
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    %%b = %%nextParam
    gosub nextParam
    %%c = %%nextParam
    gosub nextParam
    %%LIB_Function = @sendmsg(%%a,%%b,%%c,%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,SHIFT)
    gosub nextParam
    %%LIB_Function = @shift(%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,SHORTNAME)
    gosub nextParam
    %%LIB_Function = @shortname(%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,STRDEL)
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    %%b = %%nextParam
    gosub nextParam
    %%LIB_Function = @strdel(%%a,%%b,%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,STRINS)
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    %%b = %%nextParam
    gosub nextParam
    %%LIB_Function = @strins(%%a,%%b,%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,SUBSTR)
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    %%b = %%nextParam
    gosub nextParam
    %%LIB_Function = @substr(%%a,%%b,%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,SUCC)
    gosub nextParam
    %%LIB_Function = @succ(%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,SUM)
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    %%b = %%nextParam
    gosub nextParam
    %%c = %%nextParam
    gosub nextParam
    %%d = %%nextParam
    gosub nextParam
    %%e = %%nextParam
    gosub nextParam
    %%f = %%nextParam
    gosub nextParam
    %%g = %%nextParam
    gosub nextParam
    %%h = %%nextParam
    gosub nextParam
    %%i = %%nextParam
    gosub nextParam
    %%j = %%nextParam
    gosub nextParam
    %%k = %%nextParam
    gosub nextParam
    %%l = %%nextParam
    gosub nextParam
    %%m = %%nextParam
    gosub nextParam
    %%n = %%nextParam
    gosub nextParam
    %%o = %%nextParam
    gosub nextParam
    %%p = %%nextParam
    gosub nextParam
    %%q = %%nextParam
    gosub nextParam
    %%r = %%nextParam
    gosub nextParam
    %%s = %%nextParam
    gosub nextParam
    %%t = %%nextParam
    gosub nextParam
    %%u = %%nextParam
    gosub nextParam
    %%v = %%nextParam
    gosub nextParam
    %%w = %%nextParam
    gosub nextParam
    %%x = %%nextParam
    gosub nextParam
    %%y = %%nextParam
    gosub nextParam
    %%z = %%nextParam
    gosub nextParam
    %%LIB_Function = @sum(%%a,%%b,%%c,%%d,%%e,%%f,%%g,%%h,%%i,%%j,%%k,%%l,%%m,%%n,%%o,%%p,%%q,%%r,%%s,%%t,%%u,%%v,%%w,%%x,%%y,%%z,%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,SYSINFO)
    gosub nextParam
    if @equal(%%nextParam,FREEMEM)@equal(%%nextParam,PIXPERIN)@equal(%%nextParam,SCREENHEIGHT)@equal(%%nextParam,SCREENWIDTH)@equal(%%nextParam,WINVER)@equal(%%nextParam,WIN32)
      %%LIB_Function = @sysinfo(%%nextParam)
    else
      if @equal(%%nextParam,DSVER)
        %%LIB_Function = 3.51
      else
        if @equal(%%nextParam,REALDSVER)
          %%LIB_Function = @sysinfo(dsver)
        end
      end
    end
    exit
  end
  if @equal(%%LIB_Function,TAB)
    %%LIB_Function = @tab()
    exit
  end
  if @equal(%%LIB_Function,TEXT)
    gosub nextParam
    rem for lists 3 up to (infinite), the VDSLIST DLL is required
    if @both(@numeric(%%nextParam),@greater(1,@pos(@substr(%%nextParam,1,1),%%listNormal)))
      if @not(%%vdslist)
        external vdslist.dll
        %%vdslist = 1
      end
      %%LIB_Function = @lst(text,%%nextParam)
    else
      %%LIB_Function = @text(%%nextParam)
    end
    exit
  end
  if @equal(%%LIB_Function,TRIM)
    gosub nextParam
    %%LIB_Function = @trim(%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,UPPER)
    gosub nextParam
    %%LIB_Function = @upper(%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,VERINFO)
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    %%LIB_Function = @verinfo(%%a,%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,VOLINFO)
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    %%LIB_Function = @volinfo(%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,WINACTIVE)
    gosub nextParam
    %%LIB_Function = @winactive(%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,WINATPOINT)
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    %%LIB_Function = @winatpoint(%%a,%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,WINCLASS)
    gosub nextParam
    %%LIB_Function = @winclass(%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,WINDIR)
    gosub nextParam
    %%LIB_Function = @windir(%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,WINDOW)
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    %%LIB_Function = @window(%%a,%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,WINEXISTS)
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    %%LIB_Function = @winexists(%%a,%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,WINPOS)
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    %%LIB_Function = @winpos(%%a,%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,WINTEXT)
    gosub nextParam
    %%LIB_Function = @wintext(%%nextParam)
    exit
  end
  if @equal(%%LIB_Function,ZERO)
    gosub nextParam
    %%LIB_Function = @zero(%%nextParam)
    exit
  end

  rem check for external function
  %%external =
  if @not(@zero(@count(%%listDLL)))
    list seek,%%listDLL,0
  end
  repeat
    %x = @match(%%listDLL,%%LIB_Function)
    if %x
      if @equal(@item(%%listDLL),%%LIB_Function)
        %%external = @item(%%listDLL)
      end
    end
    if @greater(@sum(@index(%%listDLL),2),@count(%%listDLL))
      %x =
    else
      list seek,%%listDLL,@succ(@index(%%listDLL))
    end
  until %%external@not(%x)
  if %%external
    gosub nextParam
    %%a = %%nextParam
    gosub nextParam
    %%b = %%nextParam
    gosub nextParam
    %%c = %%nextParam
    gosub nextParam
    %%d = %%nextParam
    gosub nextParam
    %%e = %%nextParam
    gosub nextParam
    %%f = %%nextParam
    gosub nextParam
    %%g = %%nextParam
    gosub nextParam
    %%h = %%nextParam
    gosub nextParam
    %%i = %%nextParam
    gosub nextParam
    %%j = %%nextParam
    gosub nextParam
    %%k = %%nextParam
    gosub nextParam
    %%l = %%nextParam
    gosub nextParam
    %%m = %%nextParam
    gosub nextParam
    %%n = %%nextParam
    gosub nextParam
    %%o = %%nextParam
    gosub nextParam
    %%p = %%nextParam
    gosub nextParam
    %%q = %%nextParam
    gosub nextParam
    %%r = %%nextParam
    gosub nextParam
    %%s = %%nextParam
    gosub nextParam
    %%t = %%nextParam
    gosub nextParam
    %%u = %%nextParam
    gosub nextParam
    %%v = %%nextParam
    gosub nextParam
    %%w = %%nextParam
    gosub nextParam
    %%x = %%nextParam
    gosub nextParam
    %%y = %%nextParam
    gosub nextParam
    %%z = %%nextParam
    gosub nextParam
    %%LIB_Function = @rundll(%%external,%%a,%%b,%%c,%%d,%%e,%%f,%%g,%%h,%%i,%%j,%%k,%%l,%%m,%%n,%%o,%%p,%%q,%%r,%%s,%%t,%%u,%%v,%%w,%%x,%%y,%%z,%%nextParam)
    exit
  end
  
  %%LIB_Function =
  %%errorCode = 7
  exit
:LIB_Error
  %%errorCode = @error(E)
  exit
