Comment ========================================================= MarxMenu installation Menu: 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 EchoSt FileLine FileLinePtr ProgName BatExit EchoTail ConfigSysPath ConfigSysLines WorkStr DosVerNumber Const PauseTime = 100 DelFile 'MENUS.EXE' InitialDisplay Shadow Off DrawBox 25 12 31 5 DosVerNumber = DosVersion * 100 + MinorDosVersion ;MXECHO is a debugging environment variable. Use SET MXMENU=OFF for ;normal use. SET MXECHO=ON to watch the MARX.BAT run. if ReadEnv('MXECHO') > '' EchoTail = '%MXECHO%' else if ExistOnPath 'MARX.BAT' > '' EchoTail = 'OFF' else EchoTail = 'ON' endif endIf if DosVerNumber >= 330 EchoSt = '@ECHO ' + EchoTail else EchoSt = 'ECHO ' + EchoTail endif ProgName = CleanFileName(Path + '\MARXMENU.EXE') Write ' Creating MARX.BAT ... ' ;----- BatExit is a 0k bat file used to exit batch files FileAssign (BatExit,'BATEXIT.BAT') FileCreate BatExit FileClose BatExit ;----- Here we create the MARX.BAT file. ClearLineBuffer AddLine EchoSt AddLine (ProgName + ' %1') AddLine '%MXCMD%' AddLine (CleanFileName(Path + '\MARX.BAT') + ' %1') AddLine '' AddLine 'Goto ERROR1' AddLine '' AddLine '*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*' AddLine '' AddLine 'MarxMenu * CopyRight 1989-99 by Marc Perkel' AddLine '' AddLine 'Once you are confident that MarxMenu is working correctly' AddLine 'the first line of this file can be changed to ECHO OFF.' AddLine '' AddLine 'MarxMenu controls this batch file by writing to the environment' AddLine 'variable MXCMD.' AddLine '' AddLine 'MXSTOP.BAT is executed to exit this batch file.' AddLine '' AddLine '*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*' AddLine '' AddLine ' MARX.BAT' AddLine ' -------- +--MarxMenu Creates--+' AddLine ' +----> @ECHO OFF | |' AddLine ' | MARXMENU.EXE %1 |' AddLine ' | %MXCMD% >--+ +-> $MX00000.BAT' AddLine ' | +--> MARX %1 + | ------------' AddLine ' | | | +----------------------> CD\WORDSTAR' AddLine ' +-|------<-----+ WS --+' AddLine ' | |' AddLine ' +-------------------------------------------<-+' AddLine '' AddLine 'Note: MarxMenu sets MXCMD = CALL $MX00000.BAT' AddLine '' AddLine 'By Default, MarxMenu creates the temporary batch file in the same' AddLine 'directory as MARXMENU.EXE. If a second parameter is specified, and' AddLine 'the second parameter is a directory, then MarxMenu will create the' AddLine 'batch file there. If the second paramerer is a file name, then MarxMenu' AddLine 'will use it for the temporary file.' AddLine '' AddLine 'If you set and environment variable TEMP to the name of a directory,' AddLine "MarxMenu will use this directory for it's temporary batch files." AddLine '' AddLine 'Example SET TEMP=C:\TEMPFILE' AddLine '' AddLine 'The MARX.BAT file must be path accessable or you will get a' AddLine '"Bad Command or FileName" error. MARXMENU.EXE must also be path' AddLine 'accessable. The directory where MarxMenu creates temporary batch' AddLine 'files does not need to be path accessable.' AddLine '' AddLine '*-=-=-=-=-=-=-=-=-=-=[ Error Trapping Section ]-=-=-=-=-=-=-=-=-*' AddLine '' AddLine 'If you get here it is probably because you moved the MARX.BAT file' AddLine "from the directory you installed it to a new directory and didn't" AddLine 'change the path to MARXMENU.EXE and MARX.BAT in lines 2 and 4 of' AddLine 'this batch file.' AddLine '' AddLine ':ERROR1' AddLine 'CLS' AddLine 'Echo * * * * * * Warning * * * * * * *' AddLine 'Echo.' AddLine 'Echo Line 4 of this batch file does not point to the directory' AddLine 'Echo where MARX.BAT is located. Change to the directory where' AddLine 'Echo the MARXMENU files are located and type MARXMENU INST to' AddLine 'Echo re-create the MARX.BAT file for that directory.' AddLine '' AddLine 'Goto ENDBAT' AddLine '' AddLine '*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*' AddLine '' AddLine 'This exit point is used if MXSTOP.BAT can not be found. It is' AddLine 'usually caused by moving the MarxMenu files from one directory' AddLine 'to another and not copying all the BAT files. MarxMenu sets the' AddLine 'environment variable MXCMD to GOTO E in order to get here.' AddLine '' AddLine '*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*' AddLine '' AddLine ':E' AddLine 'CLS' AddLine 'Echo * * * * * * Warning * * * * * * *' AddLine 'Echo.' AddLine 'Echo The file MXSTOP.BAT, DROPTO.BAT, and BATEXIT.BAT should be in' AddLine 'Echo the same directory as the MARX.BAT file. Run MARXMENU INST in' AddLine 'Echo the directory where you want MARX.BAT to reside.' AddLine ':ENDBAT' WriteTextFile 'MARX.BAT' FileLine ClearLineBuffer ;----- Here we create the DROPTO.BAT file. Writeln Write ' Creating DROPTO.BAT ... ' AddLine 'DEL %1' AddLine 'SET KSV=' AddLine 'SET MXCMD=' AddLine '%2 %3 %4 %5 %6 %7 %8 %9' AddLine 'BATEXIT' AddLine '' AddLine '*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*' AddLine '' AddLine 'DropTo is used when you want to eliminate the temporary batch' AddLine 'file created by MarxMenu. This is useful if you shell to DOS' AddLine 'and then run MarxMenu from the dos shell. It avoids the' AddLine '"Missing Batch File" error.' AddLine '' AddLine 'DropTo is run from within the temporary batch file you want' AddLine 'to eliminate.' AddLine '' AddLine 'Usage: DROPTO %0 ' AddLine '' AddLine "Here's how it works:" AddLine '' AddLine ' $MX00000.BAT <------deletes this file--------+' AddLine ' ------------ |' AddLine ' DROPTO %0 COMMAND.COM ------------> DEL %1 >-+' AddLine ' SET KSV=' AddLine ' SET MXCMD=' AddLine ' %2 executes command.com--> %2 %3 %4 %5 %6 %7 %8 %9' AddLine '' AddLine '*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*' WriteTextFile 'DROPTO.BAT' FileLine ClearLineBuffer ;----- Here we create the MXSTOP.BAT file. Writeln Write ' Creating MXSTOP.BAT ... ' AddLine 'GOTO START' AddLine '' AddLine '*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*' AddLine '' AddLine 'This batch file is run when MarxMenu exits the MARX.BAT file. The' AddLine 'environment variable MXCMD is set to MXSTOP which causes the' AddLine 'MARX.BAT file to jump to this file.' AddLine '' AddLine 'By adding lines to the end of this file you can control what' AddLine 'happens when you exit the menu.' AddLine '' AddLine 'The %1 parameter if set is used to delete the temporary batch file.' AddLine '' AddLine '*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*' AddLine '' AddLine ':START' AddLine 'IF NOT "%1" == "" DEL %1' AddLine 'SET MXCMD=' AddLine 'SET KSV=' WriteTextFile 'MXSTOP.BAT' FileLine ClearLineBuffer MakeABatFile 'INITYME' MakeABatFile 'INIDIF' MakeABatFile 'SMITE' MakeABatFile 'WHOHAS' MakeABatFile 'USERLIST' MakeABatFile 'BINDDUMP' MakeABatFile 'ATTACH' MakeABatFile 'TRUSTEZ' MakeABatFile 'BINDEZ' MakeABatFile 'BATZAP' MakeABatFile 'WHOGOWA' MakeABatFile 'MAILCOPY' if ExistDir '\LOGIN' and NetworkVersion if not ExistFile '\LOGIN\OFF.BAT' Writeln Write ' Creating OFF.BAT ... ' AddLine 'ECHO ON' AddLine '' AddLine 'REM This batch file is used to log off the network.' AddLine 'REM Add the commands you want to execute when logoff occurs here.' AddLine '' AddLine 'LOGOUT' WriteTextFile '\LOGIN\OFF.BAT' FileLine ClearLineBuffer endif endif Wait PauseTime EraseTopWindow CheckEnvSize EraseTopWindow BoxBorderColor Yellow Mag BoxInsideColor White Mag DrawBox 18 10 44 7 BoxBorderColor LGreen Blue BoxInsideColor Yellow Blue DrawBox 23 12 34 3 WriteCenter 'MarxMenu Installed!' Wait PauseTime * 2 EraseTopWindow EraseTopWindow OnlineManuals FinalWarning ExitMenu ;--- Menu Exits Here ;===================== Procedures ======================== ;--- Check the environment size Procedure CheckEnvSize var NeededSpace ShellCommand OldComspec if EnvFree < 150 OldComspec = ReadEnv('COMSPEC') ConfigSysPath = ExistOnPath( 'CONFIG.SYS' ) NeededSpace = (EnvSize + 160) / 16 * 16 if DosVerNumber < 320 ShellCommand = Str(NeededSpace / 16) else ShellCommand = Str(NeededSpace) endif if ConfigSysPath = '' BoxBorderColor LCyan Blue BoxInsideColor White Blue DrawBox 15 8 51 13 WriteCenter '* Warning! *' Writeln char(7) Writeln ' You have a total of ' EnvSize ' bytes of environment' Writeln ' space with only ' EnvFree ' bytes free. MarxMenu' Writeln ' requires about 150 bytes of free environment' Writeln ' space. You should modify you CONFIG.SYS file' Writeln ' as follows:' Writeln WriteCenter 'SHELL=COMMAND.COM /P /E:' ShellCommand Writeln Writeln WriteCenter(' * Press any Key to Continue * ') Cursor Off LastKey = ReadKey EraseTopWindow else ReadTextFile(ConfigSysPath,ConfigSysLines) Loop ConfigSysLines WorkStr = UpperCase(LoopVal) If (NextWord( WorkStr) = 'SHELL') Delete(ConfigSysLines,LoopIndex,1) EndIf EndLoop ShellCommand = 'SHELL=' + OldComspec + ' /P /E:' + ShellCommand ConfigSysLines[NumberOfElements(ConfigSysLines) + 1] = ShellCommand WriteTextFile(ConfigSysPath,ConfigSysLines) endIf endIf EndProc Procedure AddLine ($L) FileLinePtr = FileLinePtr + 1 FileLine[FileLinePtr] = L EndProc Procedure ClearLineBuffer Dispose(FileLine) FileLinePtr = 0 EndProc Procedure MakeABatFile (St) if ExistFile (St + '.MNU') Writeln Write ' Creating ' St '.BAT ... ' AddLine EchoSt AddLine 'MARXMENU.EXE ' St ' %1 %2 %3 %4 %5 %6 %7 %8 %9' WriteTextFile St + '.BAT' FileLine ClearLineBuffer endif EndProc Procedure InitialDisplay if ColorScreen TextColor Cyan Blue ClearScreen 176 GotoXY 1 25 TextColor Yellow Mag ClearLine WriteCenter 'MarxMenu Version ' MarxVersion ' * Copyright 1989-99 by Marc Perkel' BoxBorderColor White Brown BoxInsideColor Yellow Brown BoxHeaderColor Yellow Mag ClockColor Yellow Brown TextColor Yellow Brown else ClearScreen 176 TextColor Black Grey GotoXY 1 25 ClearLine WriteCenter 'MarxMenu Version ' MarxVersion ' * Copyright 1989-99 by Marc Perkel' BoxBorderColor Black Grey BoxInsideColor Black Grey BoxHeaderColor Black Grey ClockColor Black Grey endif SingleLineBox Explode Off DrawBox 1 1 80 3 GotoXY (54,1) Write "MarxMenu Installation" ClockPos 3 2 BlankTime = 0 ScrollMove Off Explode On Shadow Off BlockBox InverseColor Yellow Red BoxBorderColor Yellow Mag BoxInsideColor Mag Mag DrawBox 10 6 61 17 BoxBorderColor LGreen Blue BoxInsideColor Yellow Blue Shadow On DrawBox 35 13 11 3 WriteCenter 'The' Loop 5 MoveWindow -4 -1 Wait 3 EndLoop DrawBox 35 13 11 3 WriteCenter 'Marx' Loop 5 MoveWindow 4 -1 Wait 3 EndLoop DrawBox 35 13 11 3 WriteCenter 'Menu' Loop 5 MoveWindow -4 1 Wait 3 EndLoop DrawBox 35 13 11 3 WriteCenter 'System' Loop 5 MoveWindow 4 1 Wait 3 EndLoop Wait 20 DrawBox 25 13 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 EndProc Procedure OnlineManuals BoxBorderColor LCyan Blue BoxInsideColor White Blue DrawBox 13 9 54 9 WriteCenter '* Latest Documentation Online *' Writeln Writeln Writeln ' Although this program comes with documentation,' Writeln ' the latest and easiest to use manuals are online' Writeln ' at http://www.ctyme.com with a search engine.' Writeln WriteCenter( ' * Press any Key to Continue * ' ) Cursor Off LastKey = ReadKey EraseTopWindow EndProc Procedure FinalWarning BoxBorderColor LCyan Blue BoxInsideColor White Blue DrawBox 14 9 52 11 WriteCenter '* Warning! *' Writeln Writeln Writeln ' One common mistake that users make is running' Writeln ' MARXMENU . You are supposed to run menus' Writeln ' by typing MARX which uses the MARX.BAT' Writeln ' file. Also, besides reading the manual, please' Writeln ' read the MARXREAD.ME file.' Writeln WriteCenter( ' * Press any Key to Continue * ' ) Cursor Off LastKey = ReadKey EraseTopWindow EndProc