Comment
=========================================================

MarxMenu installation Menu:

Copyright 1989-1990 by Marc Perkel * All rights reserved.

This is an example of how MarxMenu can be used as a job control
language. There is quite an education in MarxMenu tricks here. If
you want to write a similar program, this menu is worth studying.

=========================================================
EndComment

Var
  ForeColor, BackColor, X, ClearChar, Paths, MaxLen, YesNo, %EchoSt,
  %CallSt, PathSt, InstallPath, MarxBat, MarxBat2, WorkBat, ProgName,
  St, CurrentPath, PathBuf, FileLine, Network, NewDos

Const
  PauseTime = 100

if ColorScreen
  ForeColor = Yellow
  BackColor = Mag
  ClearChar = 32
else
  ForeColor = Black
  BackColor = Grey
  ClearChar = 177
endif

UseCommand = True
DosWindow = True
ClearScreenFirst = False
Explode On
Shadow Off
BlockBox
CurrentPath = Path
BoxHeaderColor ForeColor BackColor
BoxBorderColor Green Blue
BoxInsideColor Yellow Blue
InverseColor Yellow Red
BlankTime 10

TextColor Red Red
ClearScreen ClearChar

TextColor ForeColor BackColor
ClearLine
Write '  * The MarxMenu System *'

GotoXY(1,25)
ClearLine
WriteCenter 'Copyright 1989 by Marc Perkel * All Rights Reserved'

ClockColor ForeColor BackColor
ClockPos 37 1

BoxBorderColor Yellow Mag
BoxInsideColor Mag Mag
DrawBox 10 4 61 17
BoxBorderColor LGreen Blue
BoxInsideColor Yellow Blue
Shadow On
DrawBox 35 11 11 3
WriteCenter 'The'
X = 0
Repeat
   MoveWindow -4 -1
   X = X + 1
   Wait 3
Until X = 5
DrawBox 35 11 11 3
WriteCenter 'Marx'
X = 0
Repeat
   MoveWindow 4 -1
   X = X + 1
   Wait 3
Until X = 5
DrawBox 35 11 11 3
WriteCenter 'Menu'
X = 0
Repeat
   MoveWindow -4 1
   X = X + 1
   Wait 3
Until X = 5
DrawBox 35 11 11 3
WriteCenter 'System'
X = 0
Repeat
   MoveWindow 4 1
   X = X + 1
   Wait 3
Until X = 5
Wait 20
DrawBox 25 11 31 3
WriteCenter 'Installation Menu'
Wait 250
RollWindow 4
EraseTopWindow
Wait 20
RollWindow 3
EraseTopWindow
Wait 20
RollWindow 2
EraseTopWindow
Wait 20
RollWindow 1
EraseTopWindow
Wait 20
EraseTopWindow
EraseTopWindow
Shadow Off
BoxBorderColor Green Blue
BoxInsideColor Yellow Blue
DrawBox 53 3 25 3
WriteCenter ' Press ESC to Abort '
BoxHeader '  Install Menu  '
DrawBox 9 7 60 13
TextColor LCyan Blue
ClearLine 205
TextColor Yellow Blue
Writeln
Writeln ' This menu is designed to aid in the installation of'
Writeln ' your MarxMenu software. In order for MarxMenu to work'
Writeln ' properly, I will need information about your computer.'
Writeln ' I will be asking about which directory on the hard disk'
Writeln ' or network to install the menu system. I will be asking'
Writeln ' if you are installing MarxMenu on a network. If you'
Writeln " don't know the answer to any of the questions, you can"
Writeln ' abort the installation and start over.'
Writeln
Write   ' Are you ready to proceed'
AskYesNo
if YesNo = 'No' then ExitMenu
EraseTopWindow
BoxHeader ' Selections '
DrawBox 3 3 35 12
Writeln ' Dos Version: ' DosVersion '.' MinorDosVersion
Wait PauseTime
if NetWorkVersion
   DrawBox 3 16 45 7
   Writeln ' If you are on a Network, but you are only'
   Writeln ' running this program for the first time,'
   Writeln ' you can answer NO in order to make the'
   Writeln ' installation easier. You can re-install'
   Write   ' MarxMenu for a network at a later time.'
   DrawBox 13 11 57 3
   Write   ' Are you installing MarxMenu on a Network'
   AskYesNo
   NetWork = YesNo = 'Yes'
   EraseTopWindow
   EraseTopWindow
   Writeln ' Network: ',NetWork
   Wait PauseTime
endif
NewDos = (DosVersion > 3) or (MinorDosVersion >= 30)
if NewDos
   BoxHeader ' Advanced BATCH Commands '
   DrawBox 21 3 57 21
   TextColor LCyan Blue
   ClearLine 205
   TextColor Yellow Blue
   Writeln
   Writeln ' The version of DOS you are running is capable of'
   Writeln ' supporting advanced BATCH file commands. These'
   Writeln ' commands include "CALL" and "@ECHO OFF". Earlier'
   Writeln ' versions of DOS require that you reload your'
   Writeln ' command processor when one batch file calls another.'
   Writeln ' This costs you 3.5k of ram.'
   Writeln
   Writeln ' If you are running on a network that allows you to'
   Writeln ' mix DOS versions, and some users are running DOS'
   Writeln ' versions that are less than 3.30, or you have some'
   Writeln ' other reason to not use advanced BATCH commands,'
   Writeln ' then answer NO to the next question.'
   Writeln
   Writeln " If you don't understand any of this then trust this"
   Writeln ' program to make the right choice for you and answer'
   Writeln ' YES to the next question.'
   Writeln
   Write   ' Do you want to use advanced BATCH commands'
   AskYesNo
   NewDos = YesNo = 'Yes'
   EraseTopWindow
endif
if NewDos
   %EchoSt = '@ECHO OFF'
   %CallSt = 'CALL'
else
   %EchoSt = 'ECHO OFF'
   %CallSt = ReadEnv('COMSPEC') + ' /C '
endif
Writeln ' Advanced Commands: ' NewDos
Wait PauseTime

PathSt = ReadEnv('PATH')
if Right(PathSt,1) <> ';' then PathSt = PathSt + ';'
Paths = 1
MaxLen = 0
while PathSt > ''
   X = Pos(';',PathSt)
   if X > 0
      PathBuf[Paths] = CleanFileName(Left(PathSt,X - 1))
      PathSt = Mid(PathSt,X + 1,255)
      if length(PathBuf[Paths]) > Maxlen then MaxLen = length(PathBuf[Paths])
      Paths = Paths + 1
   endif
endwhile

BoxHeader ' About Choosing Directories '
DrawBox 40 7 38 10
TextColor LCyan Blue
ClearLine 205
TextColor Yellow Blue
Writeln
Writeln ' MarxMenu must be installed in'
Writeln ' a directory that is accessable'
Writeln ' through your PATH command. If you'
Writeln ' want to create a new directory'
Writeln ' for MarxMenu, be sure to change'
Writeln ' your AUTOEXEC.BAT file to include'
Write   ' this new directory in your PATH.'
BoxHeader ' Choose Installation Path '
DrawBox 25 18 45 6
TextColor LCyan Blue
ClearLine 205
TextColor Yellow Blue
UseArrows
Writeln
Writeln '  1) Choose a PATH Accessable Directory'
Writeln '  2) Install in Current Directory'
Write   '  3) Choose a New or Existing Directory'
InstallPath = ReadKey
EraseTopWindow
if InstallPath = char(27) then ExitMenu
if InstallPath = '2' then InstallPath = Path
if InstallPath = '3'
   DrawBox 3 18 38 5
   Writeln ' Warning: Be sure to change your'
   Writeln ' PATH command in you AUTOEXEC.BAT'
   Write   ' to include this new directory!' Char(7)
   Wait PauseTime * 4
   EraseTopWindow
   BoxHeader ' Directory for MarxMenu '
   DrawBox 20 19 58 4
   TextColor LCyan Blue
   ClearLine 205
   TextColor Yellow Blue
   Writeln
   Write ' Path: '
   InstallPath = UpperCase(Readln)
   if InstallPath = '' then ExitMenu
   EraseTopWindow
endif
if InstallPath = '1'
   BoxHeader ' Directory '
   DrawBox (20,12,(MaxLen + 6),(Min(Paths,9) + 1))
   InstallPath = PickOne PathBuf
   EraseTopWindow
endif
EraseTopWindow
if not ExistDir(InstallPath)
   DrawBox 10 19 60 4
   Writeln ' Path ' InstallPath " doesn't Exist!"
   Write   ' Create new Directory'
   AskYesNo
   EraseTopWindow
   if YesNo = 'No' then ExitMenu
   BoxHeader ' DOS Window '
   DrawBox 45 18 33 5
   Writeln ' Creating Directory '
   Execute 'MD ' + InstallPath
   if not ExistDir(InstallPath)
      ClearScreen
      Writeln ' Unable to Create Directory!'
      Write ' Program Aborting!'
      Wait PauseTime
      ExitMenu
   endif
   EraseTopWindow
endif
Writeln
Writeln ' Install Path:'
Writeln '   ' InstallPath
Wait PauseTime
WorkBat = CleanFileName(InstallPath + '\MARXRUN')
if Network
   BoxHeader ' Network Options '
   DrawBox 14 3 64 14
   TextColor LCyan Blue
   ClearLine 205
   TextColor Yellow Blue
   Writeln
   Writeln ' MarxMenu must create a separate temporary batch file for'
   Writeln ' each user. There are a number of ways to do this. The most'
   Writeln ' common is to use an environment variable that is either'
   Writeln ' set to the users name or to the station number. Another'
   Writeln ' way is to use a mapped drive to point to the users HOME'
   Writeln ' directory. This can be done with NOVELL.'
   Writeln
   Writeln ' Examples:'
   Writeln '   \PUBLIC\%USERNAME%'
   Writeln '   F:\PUBLIC\MENU\%STATION%'
   Write   '   H:MARXRUN'
   DrawBox 14 20 57 4
   Writeln ' Type in your temporary BATCH file command:'
   Write   ' '
   WorkBat = UpperCase(Readln)
   if WorkBat = '' then ExitMenu
   EraseTopWindow
   EraseTopWindow
endif
if pos('.BAT',WorkBat) > 0 then delete(WorkBat,pos('.BAT',WorkBat),255)
Writeln
Writeln ' Workfile:'
Writeln '   '  WorkBat
Wait PauseTime
BoxHeader ' DOS Window '
DrawBox 45 13 33 11
St = CleanFileName(CurrentPath + '\*.*')
if (CurrentPath = 'A:\') or (CurrentPath = 'B:\')
   Writeln ' Copying MarxMenu Files ...
   NoBoxBorder
   Explode Off
   DrawBox 47 15 30 8
   Execute 'COPY ' + St + ' ' + InstallPath
   Explode On
   BlockBox
endif
ChDir InstallPath
MarxBat = CleanFileName(InstallPath + '\MARX.BAT')
MarxBat2 = CleanFileName(InstallPath + '\MARX')
ProgName = CleanFileName(InstallPath + '\MARXMENU.EXE')
DosWindow = False
Write ' Creating MARX.BAT ... '

FileLine[1] = %EchoSt
FileLine[2] = ProgName + ' %1 ' + WorkBat + '.BAT'
FileLine[3] = 'IF ERRORLEVEL 253 GOTO J'
FileLine[4] = %CallSt + ' ' + WorkBat
FileLine[5] = MarxBat2 + ' %1'
FileLine[6] = ':J'
FileLine[7] = 'IF ERRORLEVEL 254 ' + WorkBat
FileLine[8] = 'SET KSV='

WriteTextFile 'MARX.BAT' FileLine
Dispose FileLine

Writeln
Write ' Creating DROPTO.BAT ... '

FileLine[1] = 'DEL %1'
FileLine[2] = 'SET KSV='
FileLine[3] = '%2 %3 %4 %5 %6 %7 %8 %9'

WriteTextFile 'DROPTO.BAT' FileLine
Dispose FileLine

Writeln
Write ' Creating GOFILE.BAT ... '

FileLine[1] = %EchoSt
FileLine[2] = 'MARXMENU GOFILE %1'

WriteTextFile 'GOFILE.BAT' FileLine

Writeln
Wait PauseTime
EraseTopWindow
EraseTopWindow
EraseTopWindow
BoxBorderColor Yellow Mag
BoxInsideColor Mag Mag
DrawBox 20 9 44 7
BoxBorderColor LGreen Blue
BoxInsideColor Yellow Blue
DrawBox 25 11 34 3
WriteCenter 'MarxMenu Installed!'
Wait PauseTime
EraseTopWindow
EraseTopWindow
if ExistFile 'MARXMENU.DOC'
   BoxBorderColor Green Blue
   BoxInsideColor Yellow Blue
   BoxHeader ' What Next? '
   DrawBox 25 10 34 5
   UseArrows
   TextColor LCyan Blue
   ClearLine 205
   TextColor Yellow Blue
   Writeln
   Writeln '  1) Print Documentation'
   Write   '  2) Exit Installation'
   St = ReadKey
   EraseTopWindow
   if St = '1'
      DrawBox 15 11 51 3
      Write ' Turn Printer on and Press any Key ... '
      St = ReadKey
      if St = Char(27) then ExitMenu
      ClearScreen
      Write ' Printing ... '
      Execute 'TYPE MARXMENU.DOC>PRN'
      Execute 'TYPE MARXREAD.ME>PRN'
   endif
endif
ExitMenu

Procedure AskYesNo
   Write ' (Y/N)? '
   YesNo = ''
   repeat
      YesNo = UpperCase(ReadKey)
      if YesNo = char(27) then ExitMenu
      if YesNo = 'Y' then YesNo = 'Yes'
      if YesNo = 'N' then YesNo = 'No'
   until length(YesNo) > 1
   Write YesNo
   Wait PauseTime
EndProc


