Comment ============================================================= Copyright 1990-2000 by Marc Perkel This program is used to generate a new MarxMenu and distribute the compiled files. It is an example of how to use MarxMenu as a Job Control language. Since I'm on a network, the way I test to update a file is to delete it and then update it. If someone on the net has the file open, the delete will fail. I'm doing extensive error checking here. Errors are recorded in ErrorArray. Any errors are displayed at the end. Note that in order to read error return codes from subprograms you have to use the .EXE or .COM extentions. Otherwise MarxMenu will load COMMAND.COM and the codes will be absorbed. Don't try to run this menu! It is for reading and ideas only. ============================================================= EndComment Var ThisPath ErrorArray ExecError AccessCode PMode StandardIO ClearScreenFirst Off ThisPath = Path XmsOverlays EmsOverlays Swapping if not ExistFile('MARXMENU.PAS') Writeln "This program can only be run on Marc Perkel's Computer!" Writeln "It is provided as an example only." ExitMenu endif ;------ Compile MarxComp ClearScreen Writeln '==> Compiling MarxComp ...' CompileMarxComp ;------ Marx Help CompileMarxHelp ;------ Shareware Version if ExistDir 'G:\CTYME\DOWNLOAD\SHARE' ClearScreen Writeln '==> Compiling ShareWare Version ...' ModifyMarx('Shareware','True') ModifyMarx('NetVer','True') CompileMarx if not ExecError ZipList('SHMARX.LST','MXMENU') DelFile 'MXMENU.EXE' ExecLine 'N:\MOVE.EXE MXMENU.ZIP G:\CTYME\DOWNLOAD\SHARE endif endif ;------ Single User Version ClearScreen Writeln '==> Compiling Single User Version ...' ModifyMarx('Shareware','False') ModifyMarx('NetVer','False') CompileMarx if ExistFile ('SMARX.LST') ZipList('SMARX.LST','SMarx') DelFile 'SMARX.ZIP' ExecLine 'N:\MOVE.EXE SMARX.EXE P:\SOFTWARE' endif ;------ Protected Mode Network Unlimited User Version ClearScreen Writeln '==> Compiling Protected Mode Version ...' ModifyMarx('Shareware','False') ModifyMarx('NetVer','True') PMode On CompileMarx PMode Off ExecLine 'N:\MOVE.EXE MARXMENU.EXE N:\MARXX.EXE' ExecLine 'PKZIP.EXE MARXX N:\MARXX.EXE U:DPMI16BI.OVL U:RTM.EXE' ExecLine 'N:\MOVE.EXE MARXX.ZIP G:\CTYME\DOWNLOAD\REAL' ;------ Network Unlimited User Version ClearScreen Writeln '==> Compiling Network Version ...' CompileMarx if not ExecError if ExistFile ('NMARX.LST') ZipList('NMARX.LST','NMarx') DelFile 'NMARX.ZIP' ExecLine 'N:\MOVE.EXE NMARX.EXE P:\SOFTWARE' endif ExecLine 'PKZIP.EXE MARXMENU @JMARX.LST' ExecLine 'N:\MOVE.EXE MARXMENU.ZIP G:\CTYME\DOWNLOAD\REAL' ClearScreen Writeln '==> Copying Menu files to Web ...' ExecLine 'COPY N:\*.MNU G:\CTYME\DOWNLOAD\SHARE' ExecLine 'COPY N:\*.INC G:\CTYME\DOWNLOAD\SHARE' ClearScreen Writeln '==> Updating MarxMenu ...' DelFile ('N:MARXMENU.OVR') if not ExistFile('N:MARXMENU.OVR') ClearScreen Writeln '==> Updating Network Files ...' CopyMarxFile('MARXMENU.EXE','N:') CopyMarxFile('MARXMENU.OVR','N:') CopyMarxFile('MARXCOMP.EXE','N:') else WriteErrorMsg ('MARXMENU not Updated!') endif endif ;------ Clean up ExecLine 'ZDEL.EXE MENUS.EXE MENUS2.EXE MXIDX.DOC MARXHELP.TXT MARXDOC.EXE' ExecLine 'ZDEL.EXE MARX2 *.MAP *.OLD *.BAK' ;------ Show Errors if any if NumberOfElements (ErrorArray) > 0 Writeln 'Errors:' Loop NumberOfElements(ErrorArray) Writeln '==> ' ErrorArray[LoopIndex] EndLoop else Writeln 'No Errors!' endif ExitMenu ;========================================================= ;------ Subroutines Procedure CopyMarxFile (Source,Dest) var TargetFileName if Right(Dest,1) <> ':' TargetFileName = CleanFileName(Dest + '\' + Source) else TargetFileName = CleanFileName(Dest + Source) endif DelFile(TargetFileName) if ExistFile(TargetFileName) WriteErrorMsg('File ' + Source + ' Failed to copy to ' + TargetFileName + '!') else ExecLine 'COPY ' + Source + ' ' + TargetFileName endif EndProc Procedure CompileMarx if PMode ExecLine 'T:\BPC.EXE MARXMENU /M/Q/CP' else ExecLine 'T:\BPC.EXE MARXMENU /M/Q' endif EndProc Procedure CompileMarxComp ExecLine 'BPC.EXE MARXCOMP /M/Q' ExecLine 'LZEXE.EXE MARXCOMP' if ExistFile('MARXCOMP.OVR') ExecLine 'COPY /B MARXCOMP.EXE + MARXCOMP.OVR' DelFile('MARXCOMP.OVR') endif DelFile('MARXCOMP.OLD') EndProc Procedure CompileMarxHelp ClearScreen Writeln '==> Creating MarxHelp ...' ExecLine 'BPC.EXE MXPRN /M/Q' ExecLine 'LZEXE.EXE MXPRN' DelFile('MXPRN.OLD') ExecLine 'COPY MARX2A + MARX2B + MARX2C MARX2' ExecLine 'MXDOC.EXE MARX2 MARXHELP.TXT' ExecLine 'COPY MARX2A + MARX2B + MARX2C + MXIDX.DOC MARX2' ExecLine 'MXDOC.EXE MARX2 MARXHELP.TXT' ExecLine 'MAKEHELP.EXE MARXHELP' ExecLine 'MXPRN' CopyMarxFile('MARXHELP.EXE','N:') CopyMarxFile('MARXHELP.HLP','N:') CopyMarxFile('MXPRN.EXE','N:') CopyMarxFile('MARXHELP.EXE','P:\TOOLBOX') CopyMarxFile('MARXHELP.HLP','P:\TOOLBOX') CopyMarxFile('MXPRN.EXE','P:\TOOLBOX') CopyMarxFile('MARXHELP.EXE','P:\SHTOOL') CopyMarxFile('MARXHELP.HLP','P:\SHTOOL') CopyMarxFile('MXPRN.EXE','P:\SHTOOL') CopyMarxFile('MARXMENU.DOC','N:') CopyMarxFile('TOOLBOX.DOC','N:') ExecLine 'PKZIP.EXE DOCS MARXHELP.EXE MARXHELP.HLP MXPRN.EXE' DelFile 'DOCS.EXE' ExecLine 'ZIP2EXE.EXE -J DOCS' ExecLine 'COPY DOCS.ZIP G:\CTYME\DOWNLOAD\REAL' ExecLine 'N:\MOVE.EXE DOCS.ZIP G:\CTYME\DOWNLOAD\SHARE' ExecLine 'N:\MOVE.EXE DOCS.EXE P:\SOFTWARE' EndProc Procedure ModifyMarx (KeyVar,New) var FileArray KeyWord St ReadTextFile ('MARXCPRT.PAS',FileArray) Loop NumberOfElements(FileArray) St = FileArray[LoopIndex] KeyWord = NextWord(St) if KeyWord = KeyVar FileArray[LoopIndex] = ' ' + KeyVar + ' = ' + New + ';' endif EndLoop WriteTextFile ('MARXCPRT.PAS',FileArray) EndProc Procedure ExecLine ($St) AbortGen Writeln '==> ' St Execute (St) ExecError = ReturnCode <> 0 if ExecError WriteErrorMsg ('Error ' + Str(ReturnCode) + ' while Executing: ' + St) endif Writeln EndProc Procedure ZipList (ListFile,ZipFile) ExecLine 'PKZIP.EXE ' ZipFile ' @' ListFile ExecLine 'ZIP2EXE.EXE -J ' ZipFile EndProc Procedure WriteErrorMsg (St) Writeln (Char(7) + '==> Error: ' + St) ErrorArray[NumberOfElements(ErrorArray) + 1] = St Wait 300 EndProc Procedure AbortGen var Ch if not KbdReady then return Ch = ReadKey if Ch = Esc then ExitMenu EndProc