Comment ===================================================== Saber to MarxMenu translator. Version 1.0 Copyright 1991-1994 by Marc Perkel - All rights reserved. Usage: MARXMENU SABTRANS This menu will read the Saber SRC file and produce a MarxMenu MNU file. You can then run it by typing MARX . Not everything will translate exactly like the Saber menu but it will be fairly close. ===================================================== EndComment var Sab SabName MarxName Out Menus CMenu CItem Qualifier Title Param Items Commands ShowNum Row Col ChangeDir Addpause Pswd Groups Users ;----- Translator Messages Const BottomMessage = "Translated Menu" ;----- If you want the Greek Column effect, set to true StandardIO SabName = UpperCase(ParamStr(2)) MarxName = UpperCase(ParamStr(3)) if SabName = '' Writeln Writeln 'Saber Menu to MarxMenu Translator * Version 1.0 * Release Date: 03-15-93. Writeln 'Copyright 1991-1994 by Marc Perkel * All Rights Reserved' Writeln Writeln 'Computer Tyme * 309 North Jefferson, #220 * Springfield Mo. 65806' Writeln '417-866-1222 voice * 417-866-0135 fax * 417-866-1665 bbs' Writeln Writeln 'This program is FREE to Everyone.' Writeln if Extension MenuFileName = 'EXE' Writeln 'Usage: SABTRANS ' else Writeln 'Usage: MARXMENU SABTRANS ' endif Writeln Writeln 'This program will read the NMenu or Saber SRC file' Writeln 'and create a MarxMenu MNU file.' Writeln Writeln 'SABER is a trademark of Saber Software Inc.' ExitMenu endif if Extension (SabName) = '' then Extension (SabName) = 'SRC' if MarxName > '' if Extension (MarxName) = '' then Extension (MarxName) = 'MNU' else MarxName = SabName Extension (MarxName) = 'MNU' endif ReadTextFile (SabName,Sab) TranslateSab BuildMarx ClearScreenFirst Off if ExistOnPath 'MARXCOMP.EXE' > '' Execute 'MARXCOMP.EXE ' + MarxName endif ExitMenu ;----- Translation Procedures Procedure TranslateSab var KeyWord X P Q MenuNum ItemNum CommandNum Prm Writeln Writeln 'Translating Saber Menu ....' Loop Sab if LoopIndex mod 10 = 0 Write CR 'Processing Line: ' LoopIndex endif X = pos(';',LoopVal) if X > 0 then LoopVal = Left(LoopVal,pred(X)) Trim(LoopVal) KeyWord = UpperCase(NextWord(LoopVal)) if KeyWord = 'MENU' ItemNum = 0 MenuNum = Value(NextWord(LoopVal)) Actual CMenu = Loc Menus[MenuNum] CMenu.Param = '' CMenu.Row = 0 CMenu.Col = 0 if LoopVal StartsWith ',' then delete(LoopVal,1,1) CMenu.Title = LoopVal X = pos('{',LoopVal) if X > 0 CMenu.Title = left(LoopVal,pred(X)) CMenu.Param = mid(LoopVal,succ(X),255) X = pos('}',CMenu.Param) if X > 0 then CMenu.Param = left(CMenu.Param,pred(X)) endif Trim(CMenu.Title) Trim(CMenu.Param) CMenu.Param = UpperCase(CMenu.Param) if CMenu.Param > '' X = pos('ROW',CMenu.Param) if X > 0 P = mid(CMenu.Param,X + 4,255) CMenu.Row = Value(NextWord(P)) endif X = pos('COL',CMenu.Param) if X > 0 P = mid(CMenu.Param,X + 4,255) CMenu.Col = Value(NextWord(P)) endif endif endif if KeyWord = 'ITEM' CommandNum = 0 ItemNum = ItemNum + 1 Actual CItem = Loc Menus[MenuNum].Items[ItemNum] CItem.Param = '' if pos('SEPARATOR',LoopVal) = 0 CItem.Title = LoopVal X = pos('{',LoopVal) if X > 0 CItem.Title = left(LoopVal,pred(X)) Trim(CItem.Title) CItem.Param = mid(LoopVal,succ(X),255) X = pos('}',CItem.Param) if X > 0 then CItem.Param = left(CItem.Param,pred(X)) endif Trim(CItem.Title) while pos(' ',CItem.Title) > 0 delete(CItem.Title,pos(' ',CItem.Title),1) endwhile Trim(CItem.Param) CItem.Param = UpperCase(CItem.Param) Prm = CItem.Param CItem.ChangeDir = pos('CHDIR',Prm) > 0 CItem.AddPause = pos('PAUSE',Prm) > 0 X = pos('PSWD=',Prm) if X > 0 P = Mid(Prm,X + 5,255) CItem.Pswd = NextWord(P) endif X = pos('GROUPS=',Prm) if X > 0 P = Mid(Prm,X + 7,255) Trim(P) X = pos(' ',P) if X > 0 then P = left(P,pred(X)) repeat AppendArray(CItem.Groups,NextWord(P)) until P = '' endif X = pos('USERS=',Prm) if X > 0 P = Mid(Prm,X + 6,255) Trim(P) X = pos(' ',P) if X > 0 then P = left(P,pred(X)) repeat AppendArray(CItem.Users,NextWord(P)) until P = '' endif else CItem.Title = Char(196) endif endif if KeyWord = 'EXEC' Trim(LoopVal) if LoopVal > '' CommandNum = CommandNum + 1 if LoopVal = 'EXIT' then LoopVal = '|ExitMenu' if LoopVal = 'LOGOUT' then LoopVal = '|LogOff' CItem.Commands[CommandNum] = LoopVal endif endif if KeyWord = 'SHOW' CItem.ShowNum = Value(NextWord(LoopVal)) endif EndLoop Writeln CR 'Processing Line: ' NumberOfElements Sab Writeln EndProc Procedure BuildMarx var X TaskNum SomeGroups SomeUsers Cond St Header Loop Menus if LoopVal.Title > '' Actual CMenu = Loc LoopVal WriteOut Writeln 'Translating: ',CMenu.Title WriteOut ';----- Translating: ',CMenu.Title WriteOut WriteOut ':Menu',LoopIndex WriteOut Loop CMenu.Items TaskNum = LoopIndex if LoopVal.Title = Char(196) TaskNum = 0 endif SomeGroups = NumberOfElements LoopVal.Groups > 0 if SomeGroups St = '' Loop LoopVal.Groups St = St + '"' + LoopVal + '",' EndLoop delete(St,length(St),1) FileWriteln(Out,'if InGroup(' St ')') FileWrite(Out,' ') endif SomeUsers = NumberOfElements LoopVal.Users > 0 if SomeUsers Cond = 'if' Loop LoopVal.Users FileWrite(Out,Cond,' (NovLoginName = "',LoopVal,'") ') Cond = 'or' EndLoop FileWriteln(Out) FileWrite(Out,' ') endif WriteOut 'AddChoice("',LoopVal.Title,'",',Str(TaskNum),')' if SomeGroups or SomeUsers WriteOut 'endif' endif EndLoop WriteOut WriteOut ' CornerStretchBox("',CMenu.Title,'",',CMenu.Col,',',CMenu.Row,')' Loop CMenu.Items WriteOut WriteOut ' OnKey Task(',LoopIndex,')' if LoopVal.ShowNum > 0 St = ' ^Menu' + Str(LoopVal.ShowNum) Mid(St,24) = ';' + LoopVal.Title WriteOut St else if LoopVal.Pswd > '' WriteOut ' |if not GetPassword("',LoopVal.Pswd,'") then Return' endif Loop LoopVal.Commands WriteOut ' ' LoopVal EndLoop if LoopVal.ChangeDir WriteOut ' |Bat "CD " + ThisDir' endif if LoopVal.AddPause WriteOut ' Pause' endif endif EndLoop if LoopIndex = 1 WriteOut WriteOut ' OnKey ESC' WriteOut ' |if NovConsoleOperator or not KeepUsersInMenu' WriteOut ' | LeaveMenu' WriteOut ' |endif' WriteOut Endif endif EndLoop Footer EndProc ;----- Write out the MarxMenu Source Header Procedure Header FileAssign(Out,MarxName) FileCreate(Out) WriteOut WriteOut 'Comment' WriteOut '==========================================================' WriteOut WriteOut 'This File was converted from Saber Menu: ',SabName WriteOut WriteOut 'It should behave in a similar way to the original menu but' WriteOut 'not necessarilly exactly the same. It will be close enough' WriteOut 'for you to fine tune it the way you want.' WriteOut WriteOut 'To add a choice to a menu simply use the AddChoice command' WriteOut 'then add the appropiate Onkey statement.' WriteOut 'The menu will make the size adjustments accordinaly.' WriteOut WriteOut ' Example:' WriteOut ' AddChoice("Print Console",10)' WriteOut ' ...' WriteOut ' ...' WriteOut ' OnKey Task(10)' WriteOut ' PConsole' WriteOut ' ...' WriteOut WriteOut "If you want to change the menu's center, pass the XY" WriteOut "coordinates to menu's CenterStretchBox procedure." WriteOut WriteOut ' Example:' WriteOut ' CenterStretchBox("Menu Header",10,10)' WriteOut WriteOut 'This will cause the menu to center at Col 10, Row 10' WriteOut WriteOut 'To control custom features, edit CUSTOM.INC and other INCLUDE Files.' WriteOut WriteOut '=========================================================' WriteOut 'EndComment' WriteOut WriteOut ';----- Create Variables' WriteOut WriteOut 'var' WriteOut ' KeepUsersInMenu' WriteOut ' ThisDir' WriteOut WriteOut WriteOut ';----- Here is where you add you own menu title and status line message' WriteOut WriteOut 'StatusLineText = "',BottomMessage,'"' WriteOut 'MenuTitle = "User: " + NovLoginName' WriteOut WriteOut ';----- Load look and feel routines' WriteOut WriteOut 'Include "CUSTOM.INC"' WriteOut WriteOut 'KeepUsersInMenu Off' WriteOut 'ThisDir = CurrentDirectory' WriteOut WriteOut 'Comment' WriteOut '=================================' WriteOut WriteOut 'In order to add menu choices conditionally you would append the' WriteOut 'choices to the end of the array after all the default choices' WriteOut 'are set. For Example:' WriteOut WriteOut ' if InGroup("ACCOUNTING","MANAGERS")' WriteOut ' AddChoice("Payroll Menu",10)' WriteOut ' endif' WriteOut WriteOut 'Here is where menus are created.' WriteOut WriteOut '=================================' WriteOut 'EndComment' WriteOut FileFlush(Out); EndProc ;----- Write out the MarxMenu Source Footer Procedure Footer WriteOut WriteOut ';----- End of Menu' FileClose(Out) EndProc Procedure WriteOut ($OutSt) FileWriteln(Out,OutSt) EndProc