Comment ========================================================== Computer Tyme IniTyme * Copyright 1993-2000 by Marc Perkel All Rights Reserved Computer Tyme * http://www.ctyme.com marc@ctyme.com IniTyme is a Windows *.INI file manipulator. It is designed to assist the network administrator who has to maintain INI files for many users. USAGE: INITYME ChangeFile IniFile Example: INITYME CHANGE.CTL SYSTEM.INI This file and INITYME.INC are the source code files written in MarxMenu. If your running INITYME.EXE you don't need these two files to run. If you have MarxMenu then you can customize INITYME and run it as a MarxMenu script: Example: MARXMENU INITYME CHANGE.CTL SYSTEM.INI See INITYME.HLP for detailed instructions. ========================================================== EndComment ;#Define McAfee ;#Define Shareware ;#Define MarxErrors ;------ Create Variables var Orig KOrig Changes UChanges NameIndex BlockStartIndex BlockEndIndex CurrentSection ThisSection NeedsIndexing SectionStart SectionEnd SubFind SubReplace SubFindG SubReplaceG GroupSection GroupSectionNumber GroupMode GroupAdded Sections InsertPos Logging LogHandle LogGroup LogFirstLine NoBackup RestoreMode TestMode ChangeFileName IniFileName StDelim Yak Quiet GlobalDups BackupExtension BackupName FirstProcessFile ProgName CleanNoEquals CleanEmptySections CommaMode var IfArray Stack GotoList IfLine ParenLevel Main ;======================= P R O C E D U R E S =========================== Procedure IndexFile var LastTextLine St Loop Orig Trim(LoopVal) St = CleanIniLine(LoopVal) if St StartsWith '[' ;-- Process Header ThisSection = St GroupSection = (ThisSection = '[GROUPS]') or (ThisSection = '[NETMENU]') CurrentSection = CurrentSection + 1 AppendArray(NameIndex,St) AppendArray(BlockStartIndex,succ(LoopIndex)) if CurrentSection > 1 AppendArray(BlockEndIndex,LastTextLine) endif LastTextLine = succ(LoopIndex) else if St > '' LastTextLine = LoopIndex KOrig[LoopIndex] = KeyString(St) endif endif EndLoop Sections = CurrentSection CurrentSection = 0 if Sections > 0 AppendArray(BlockEndIndex,LastTextLine) endif NeedsIndexing = False TestFreeMemory EndProc Procedure KeyString (St) var KeyWord KeyWord = LeftOfEqual(St) ;-- Allows addition of lines without = sign if KeyWord = '' KeyWord = St endif if Hash(KeyWord + ThisSection) ;- duplicates allowed Return St endif GroupMode = False if GroupSection if St StartsWith 'GROUP' GroupMode = True KeyWord = 'GROUP=' + FilePart(RightOfEqual(St)) endif endif Return KeyWord EndProc ;----- When adding or deleting the BlockStartIndex must be updated Procedure AdjustLineIndex (Line, Adj) Loop BlockStartIndex if LoopVal > Line LoopVal = LoopVal + Adj endif EndLoop Loop BlockEndIndex if LoopVal >= (Line - Adj) LoopVal = LoopVal + Adj endif EndLoop if CurrentSection > 0 SectionStart = BlockStartIndex[CurrentSection] SectionEnd = BlockEndIndex[CurrentSection] endif if InsertPos >= Line InsertPos = InsertPos + Adj endif EndProc Procedure LogEvent ($St) if Logging if LogGroup <> ThisSection if (LogGroup <> '') or LogFirstLine ;- First line of this log session if LogFirstLine FileLog(LogHandle,'') FileLog(LogHandle,'======================================================') FileLog(LogHandle,'') FileLog(LogHandle,'MainFile=' + IniFileName) FileLog(LogHandle,'ChangeFile=' + ChangeFileName) if NovLoginName > '' FileLog(LogHandle,'User=' + NovLoginName) endif FileLog(LogHandle,'Time: ' + DateString + ' ' + TimeString) FileLog(LogHandle,'') FileLog(LogHandle,'======================================================') endif FileLog(LogHandle,'') if Yak then Writeln FileLog(LogHandle,ThisSection) if Yak then Writeln ThisSection endif LogFirstLine = False LogGroup = ThisSection endif FileLog(LogHandle,St) endif if Yak then Writeln St EndProc Procedure DelLine (Line) if Line = 0 then Return LogEvent ' Deleted: ' Orig[Line] Delete(Orig,Line,1) Delete(KOrig,Line,1) AdjustLineIndex(Line,-1) EndProc Procedure InsertLine (St,Line) ArrayInsert(Orig,Line,1) ArrayInsert(KOrig,Line,1) Orig[Line] = St KOrig[Line] = KeyString(CleanINILine(Orig[Line])) EndProc ;----- Change a line, 0 for line number adds line Procedure ChangeOrAddLine (St,Line) var Original if Line = 0 ;- add new line if CurrentSection > 0 if GroupMode St = 'Group' + Str(NextGroup) + '=' + RightOfEqual(St) endif ;- Determine Insert Position if InsertPos = 0 Line = BlockEndIndex[CurrentSection] + 1 InsertLine(St,Line) AdjustLineIndex(Line,1) else Line = InsertPos InsertPos = 0 InsertLine(St,Line) AdjustLineIndex(Line,1) endif LogEvent ' Added: ' St endif else ;- change line Original = Orig[Line] if InsertPos > 0 ;- move the line Delete(Orig,Line,1) Delete(KOrig,Line,1) Line = InsertPos InsertLine(St,Line) InsertPos = 0 endif if GroupMode St = LeftOfEqual(Orig[Line]) + RightOfEqual(St) endif if St <> Original LogEvent ' Changed: ' Original ' to ' St Orig[Line] = St KOrig[Line] = KeyString(CleanIniLine(Orig[Line])) endif endif EndProc Procedure SetSectionInfo InsertPos = 0 if CurrentSection = 0 ThisSection = '' GroupSection = False SectionStart = 0 SectionEnd = 0 else ThisSection = NameIndex[CurrentSection] SectionStart = BlockStartIndex[CurrentSection] SectionEnd = BlockEndIndex[CurrentSection] GroupSection = (ThisSection = '[GROUPS]') or (ThisSection = '[NETMENU]') HashLevel = 2 Loop GlobalDups Hash(LoopVal + ThisSection) = True EndLoop HashLevel = 1 endif EndProc Procedure FindSection (St) if NeedsIndexing then IndexFile CurrentSection = PosInList(St,NameIndex) SetSectionInfo EndProc Procedure AddSection (St) var Lines Proc Proc = CleanIniLine(St) ;- Add a blank line AppendArray(Orig,'') AppendArray(KOrig,'') ;- Add CurrentSection header AppendArray(Orig,St) AppendArray(KOrig,Proc) ;- Update Indexes Lines = NumberOfElements(Orig) AppendArray(NameIndex,Proc) AppendArray(BlockStartIndex,Lines + 1) AppendArray(BlockEndIndex,Lines + 1) ;- Make new CurrentSection the current CurrentSection CurrentSection = NumberOfElements(NameIndex) SetSectionInfo if Logging LogGroup = UpperCase(St) LogEvent '' LogEvent LogGroup ' -*- Section Added' endif EndProc Procedure DelSection (St) var S E D FindSection(St) if CurrentSection = 0 then Return S = BlockStartIndex[CurrentSection] - 1 E = BlockEndIndex[CurrentSection] D = E - S + 1 delete(Orig,S,D) delete(KOrig,S,D) delete(NameIndex,CurrentSection,1) delete(BlockStartIndex,CurrentSection,1) delete(BlockEndIndex,CurrentSection,1) CurrentSection = 0 AdjustLineIndex(S,0 - D) SetSectionInfo if Logging LogGroup = '' LogEvent '' LogEvent UpperCase(St) ' -*- Section Deleted' endif EndProc Procedure FindLine (St) Return PosInList(KeyString(St),KOrig,SectionStart,SectionEnd) EndProc ;----- Replaces text in block from the list of substitute text. Procedure ApplySubstBlock (SubF,SubR,S,E) var P St if NumberOfElements(SubF) = 0 then Return while S <= E Loop SubF St = Orig[S] Substitute(Orig[S],SubF[LoopIndex],SubR[LoopIndex]) if St <> Orig[S] then ChangeOrAddLine(Orig[S],S) EndLoop S = S + 1 endwhile dispose(SubFind) dispose(SubReplace) EndProc Procedure ApplySubst if CurrentSection = 0 then Return ApplySubstBlock(SubFind,SubReplace,BlockStartIndex[CurrentSection],BlockEndIndex[CurrentSection]) ApplySubstBlock(SubFindG,SubReplaceG,BlockStartIndex[CurrentSection],BlockEndIndex[CurrentSection]) EndProc Procedure NextGroup var X S E St Match GroupAdded = True GroupSectionNumber = CurrentSection X = 1 repeat S = BlockStartIndex[CurrentSection] E = BlockEndIndex[CurrentSection] Match = False while (S <= E) and not Match St = 'GROUP' + Str(X) Match = pos(St,CleanIniLine(Orig[S])) > 0 S = S + 1 endwhile if not Match then Return X X = X + 1 Forever EndProc Procedure SetOrderLine var St Order Loop BlockStartIndex[GroupSectionNumber] BlockEndIndex[GroupSectionNumber] Orig St = UpperCase(LeftOfEqual(LoopVal)) if St StartsWith 'GROUP' delete(St,1,5) delete(St,Length(St),1) Order = Order + ' ' + St endif EndLoop Trim(Order) FindSection('[SETTINGS]') if CurrentSection > 0 ChangeOrAddLine('Order=' + Order,FindLine('ORDER=')) endif EndProc Procedure GoodLine (St) var B Return (St StartsWith '[') or (St StartsWith ';') or (St Contains '=') EndProc Procedure RemoveExtraBlankLines var Tmp EmptySection ;- Remove Blank Lines Trim(Orig) Tmp = Orig dispose Orig Loop Tmp if LoopVal > '' TrimTrail(LoopVal) AppendArray(Orig,LoopVal) endif EndLoop ;- Remove Junk Lines if CleanNoEquals Tmp = Orig dispose Orig Loop Tmp if GoodLine(LoopVal) AppendArray(Orig,LoopVal) endif EndLoop endif ;- Remove Empty Sections if CleanEmptySections Tmp = Orig dispose Orig Loop Tmp EmptySection = False if LoopVal StartsWith '[' if LoopIndex = LoopLimit EmptySection = True elseif (Tmp[LoopIndex + 1] StartsWith '[') EmptySection = True endif endif if not EmptySection AppendArray(Orig,LoopVal) endif EndLoop endif Tmp = Orig dispose Orig Loop Tmp if LoopIndex > 1 if LoopVal StartsWith '[' AppendArray(Orig,'') endif endif AppendArray(Orig,LoopVal) EndLoop EndProc Procedure CleanCommas (St) var P Substitute(St,',',' ') repeat P = pos(' ',St) if P > 0 then delete(St,P,1) until P = 0 EndProc Procedure AddItem (Line) var St St2 List New UNew NewLine Next UNext St = CleanIniLine(Orig[Line]) New = RightOfEqual(Changes[LoopIndex]) UNew = RightOfEqual(UChanges[LoopIndex]) CleanCommas(loc New) CleanCommas(loc UNew) St = RightOfEqual(St) NewLine = Orig[Line] if CommaMode Substitute(Newline,',',', ') endif while St > '' AppendArray(List,NextWordDelim(St,StDelim)) endwhile while UNew > '' Next = NextWordDelim(New,StDelim); UNext = NextWordDelim(UNew,StDelim); if PosInList(UNext,List) = 0 if CommaMode NewLine = NewLine + ', ' + Next else NewLine = NewLine + ' ' + Next endif endif endwhile TrimTrail(NewLine) if Right(NewLine,1) = ',' Length(NewLine) = Length(Newline) - 1 endif ;- delete double spaces while pos(' ',NewLine) > 0 Delete(NewLine,pos(' ',NewLine),1) endwhile ;- delete space after = if pos('= ',NewLine) > 0 Delete(NewLine,pos('= ',NewLine)+1,1) endif ChangeOrAddLine(NewLine,Line) EndProc Procedure DelItem (Line) var St List New UNew NewLine Next UNext P E St = CleanIniLine(Orig[Line]) UNew = RightOfEqual(UChanges[LoopIndex]) CleanCommas(Loc UNew) St = St + ' ' NewLine = Orig[Line] CleanCommas(Loc NewLine) while UNew > '' UNext = NextWordDelim(UNew,StDelim); P = pos(UNext + ' ',St) if P > 0 delete(St,P,length(UNext) + 1) delete(NewLine,P,length(UNext) + 1) endif endwhile TrimTrail(NewLine) ;- delete double spaces while pos(' ',NewLine) > 0 Delete(NewLine,pos(' ',NewLine),1) endwhile ;- delete space after = if pos('= ',NewLine) > 0 Delete(NewLine,pos('= ',NewLine)+1,1) endif if CommaMode Substitute(NewLine,' ',', ') endif ChangeOrAddLine(NewLine,Line) EndProc Procedure TrailEqu (St) if St contains '=' Return St else Return St + '=' endif EndProc Procedure OpenLog (RestOfLine) var LogFileName LogFileName = RestOfLine if LogFileName = '' LogFileName = ForceExtension(IniFileName,'LOG') endif LogFileName = DefaultExtension(LogFileName,'LOG') FileAssign(LogHandle,LogFileName) LogFirstLine Logging EndProc Procedure ChangeFile var St New Line Tmp FirstWord RestOfLine LogFileName X Y FileName Loop Changes #If not MarxErrors ErrorLineNumber = LoopIndex #Endif New = LoopVal St = UChanges[LoopIndex] if St > '' RestOfLine = St FirstWord = NextWordDelim(RestOfLine,'') if Hash(FirstWord) St = RestOfLine Tmp = NextWord(New) if CurrentSection = 0 if FirstWord = 'TESTMODE' TestMode elseif FirstWord = 'LOG' OpenLog(RestOfLine) FileCreate(LogHandle) elseif FirstWord = 'APPENDLOG' OpenLog(RestOfLine) FileAppend(LogHandle) elseif FirstWord = 'NOBACKUP' NoBackup = True elseif FirstWord = 'CLEANNOEQUALS' CleanNoEquals = True elseif FirstWord = 'CLEANEMPTYSECTIONS' CleanEmptySections = True elseif FirstWord = 'YAK' if not Quiet Writeln Yak = True endif elseif FirstWord = 'BACKUPNAME' BackupName = Uppercase(NextWordDelim(RestOfLine,StDelim)) if BackupName StartsWith '*.' BackupExtension = BackupName delete(BackupExtension,1,2) BackupName = '' endif elseif FirstWord = 'DUPLICATES' if RightOfEqual(RestOfLine) = '[*]' AppendArray(GlobalDups,LeftOfEqual(RestOfLine)) else HashLevel = 2 Hash(RestOfLine) = True HashLevel = 1 endif LoopVal = '' UChanges[LoopIndex] = '' endif endif if FirstWord = 'DEL' if RestOfLine StartsWith '[' ApplySubst DelSection(RestOfLine) else RestOfLine = TrailEqu(RestOfLine) DelLine(FindLine(RestOfLine)) endif elseif FirstWord = 'ADD' Line = FindLine(St) if Line = 0 ChangeOrAddLine(New,0) endif elseif FirstWord = 'CHANGE' Line = FindLine(St) if Line > 0 ChangeOrAddLine(New,Line) endif elseif FirstWord = 'ADDVALUE' Line = FindLine(St) if Line > 0 X = Value(RightOfEqual(New)) + Value(RightOfEqual(Orig[Line])) Tmp = LeftOfEqual(New) ChangeOrAddLine(Tmp + Str(X),Line) endif elseif FirstWord = 'ADDITEM' CommaMode Off Line = FindLine(St) if Line > 0 AddItem(Line,St) else ChangeOrAddLine(New,0) endif elseif FirstWord = 'DELITEM' CommaMode Off Line = FindLine(St) if Line > 0 DelItem(Line,St) endif elseif FirstWord = 'ADDITEMCOMMA' CommaMode On Line = FindLine(St) if Line > 0 AddItem(Line,St) else ChangeOrAddLine(New,0) endif elseif FirstWord = 'DELITEMCOMMA' CommaMode On Line = FindLine(St) if Line > 0 DelItem(Line,St) endif elseif FirstWord = 'SUBST' if CurrentSection = 0 AppendArray(SubFindG,CleanIniLine(NextWord(St))) Tmp = NextWord(New) AppendArray(SubReplaceG,NextWord(New)) else AppendArray(SubFind,CleanIniLine(NextWord(St))) Tmp = NextWord(New) AppendArray(SubReplace,NextWord(New)) endif elseif FirstWord = 'BEFORE' St = TrailEqu(St) InsertPos = FindLine(St) elseif FirstWord = 'AFTER' St = TrailEqu(St) X = FindLine(St) if X > 0 then InsertPos = succ(X) elseif FirstWord = 'FIRST' InsertPos = BlockStartIndex[CurrentSection] endif else ;- Process Sections if St StartsWith '[' ;- New Group ApplySubst FindSection(St) if CurrentSection = 0 AddSection(LoopVal) endif else ;- Process Lines ChangeOrAddLine(New,Findline(St)) endif endif endif IfLine = IfArray[LoopIndex] if IfLine > '' Interpret if NumberOfElements Stack <> 0 Error ('Too Many Parameters!',LoopIndex) endif endif if ExitFlag then LoopIndex = LoopLimit EndLoop ApplySubst ApplySubstBlock(SubFindG,SubReplaceG,1,NumberOfElements(Orig)) if GroupAdded then SetOrderLine EndProc Procedure Help var Help HelpFile St St = ForceExtension(FilePart(MenuFileName),'HLP') HelpFile = ExistOnPath(St) if HelpFile = '' St = ForceExtension(FilePart(MenuFileName),'TXT') HelpFile = ExistOnPath(St) endif { Writeln if HelpFile > '' BoxHeader ' Viewing ' + HelpFile + ' ' DrawBox 1 1 ScreenWidth ScreenHeight ViewTextFile(HelpFile) endif} StandardIO Writeln ProgName ' * Version 2.58 * Release Date: 12-21-00' Writeln 'Copyright 1993-99 by Marc Perkel * All Rights Reserved' #If McAfee Writeln Writeln 'Licensed to Network Associates Inc. from Marc Perkel' Writeln Writeln 'This software will expire on 07-01-2000' Writeln 'Contact Computer Tyme for License Extension Information' #Endif Include 'ADDRESS.INC' Writeln 'Price: $95/25 Users * $500/250 Users * $2500/2500 Users' Writeln 'For unusual and quantity pricing, please call.' Writeln Writeln 'USAGE: INITYME controlfile inifile' Writeln Writeln 'For help, read the file: ' HelpFile Writeln 'Do not use this program on BAT files. Use BatZap instead.' ExitMenu EndProc #If Shareware { Procedure Beg BoxHeader ' * Shameless Beg Screen * ' DrawBox 10 8 61 6 Writeln #If McAfee WriteCenter '* IniTool Evaluation Copy *' #Else WriteCenter '* IniTyme Evaluation Copy *' #Endif Writeln WriteCenter 'Please remember to register this software.' Wait 600 EraseTopWindow ClearKbdBuffer EndProc } Procedure Beg WritelnError #If McAfee WritelnError '* IniTool Evaluation Copy *' #Else WritelnError '* IniTyme Evaluation Copy *' #Endif WritelnError WritelnError 'Please remember to register this software.' WritelnError ClearKbdBuffer EndProc #Endif Procedure TestFreeMemory if FreeMemory < 10000 Error('Not Enough Free Memory!',0) endif EndProc Procedure Error (St,Line) StandardIO Writeln if Line > 0 Writeln ProgName ' Error in line ' Line Writeln St else Writeln ProgName ' Error: ' St endif ExitCode = 1 ExitMenu EndProc ;----- INITYME.INC has the conditional logic. Include 'INITYME.INC' Procedure LookForCtlFile (Name) var St ;- IniTools Names Name = ForceExtension(Name,'CTL') St = ExistOnPath(Name) if St > '' then Return St St = CleanFileName(%CTLDIR% + '\' + Name) if ExistFile (St) then Return St ;- IniMan Names Name = ForceExtension(Name,'DEF') St = ExistOnPath(Name) if St > '' then Return St St = CleanFileName(%S_CONFIG% + '\' + Name) if ExistFile (St) then Return St Return '' EndProc Procedure ProcessChangeFile var St P ReadTextFile(ChangeFileName,Changes) Loop Changes Trim(LoopVal) LoopVal = EnvExpandString(LoopVal) UChanges[LoopIndex] = CleanIniLine(LoopVal) EndLoop Loop UChanges if LoopVal StartsWith 'IF ' IfArray[LoopIndex] = LoopVal LoopVal = '' Changes[LoopIndex] = '' PushStack(LoopIndex) elseif LoopVal StartsWith 'WRITE ' IfArray[LoopIndex] = LoopVal LoopVal = '' Changes[LoopIndex] = '' elseif LoopVal StartsWith 'WRITELN ' IfArray[LoopIndex] = LoopVal LoopVal = '' Changes[LoopIndex] = '' elseif LoopVal StartsWith 'FILEWRITELN ' IfArray[LoopIndex] = LoopVal LoopVal = '' Changes[LoopIndex] = '' elseif LoopVal StartsWith '**' ;================= IniMan Code Begins ================== delete(LoopVal,1,2) St = LoopVal St = NextWordDelim(St,'=') if St = 'BEGIN' LoopVal = '' elseif St = 'END' LoopVal = '' elseif St = 'REV' ;- Not Supported LoopVal = '' elseif St = 'ELSE' IfArray[LoopIndex] = 'GOTO' P = 0 Loop LoopIndex + 2 LoopLimit UChanges ;- Search forward for END if LoopVal = '**END' P = LoopIndex LoopIndex = LoopLimit endif EndLoop if P > 0 GotoList[LoopIndex] = P else P = LoopLimit endif elseif HashExist('!' + St) ;= Iniman Conditional Keyword LoopVal = 'IF ' + LoopVal IfArray[LoopIndex] = LoopVal P = 0 if UChanges[LoopIndex + 1] = '**BEGIN' Loop LoopIndex + 2 LoopLimit UChanges ;- Search forward for END if LoopVal = '**END' P = LoopIndex LoopIndex = LoopLimit elseif LoopVal = '**ELSE' P = LoopIndex LoopIndex = LoopLimit endif EndLoop if P = 0 then P = LoopLimit GotoList[LoopIndex] = P elseif UChanges[LoopIndex + 1] StartsWith '[' ;- Conditional applies to section Loop LoopIndex + 2 LoopLimit UChanges ;- Search forward for next [Section] if LoopVal StartsWith '[' P = LoopIndex LoopIndex = LoopLimit endif EndLoop if P = 0 P = LoopLimit else ;- back up to end of section P = P - 1 while UChanges[P] StartsWith '**' P = P - 1 endwhile endif GotoList[LoopIndex] = P else GotoList[LoopIndex] = LoopIndex + 1 endif endif LoopVal = '' Changes[LoopIndex] = '' ;================= IniMan Code Ends ================== elseif LoopVal = 'ENDIF' LoopVal = '' Changes[LoopIndex] = '' GotoList[PopStack] = LoopIndex elseif LoopVal = 'ELSE' LoopVal = '' Changes[LoopIndex] = '' IfArray[LoopIndex] = 'GOTO' GotoList[PopStack] = LoopIndex PushStack(LoopIndex) endif EndLoop ;-- if you forgot an Endif then the stack contains values. if NumberOfElements Stack <> 0 Error ('MisMatched Conditionals!',0) endif EndProc Procedure Setup var St TestFreeMemory UpperCaseCompare On ; LfnSupported Off StDelim = ',"' + "'" BlankTime = 0 BoxBorderColor Green Blue BoxInsideColor White Blue BoxHeaderColor Yellow Mag #If Shareware Beg #Endif Quiet = OptionSwitch(CmdLine,'Q') BackupExtension = 'BNI' FirstProcessFile = True ChangeFileName = ParamStr(2) IniFileName = ParamStr(3) #If McAfee ProgName = 'IniTool' #Else ProgName = 'IniTyme' #Endif ExitCode = 0 RestoreMode = ChangeFileName = 'RESTORE' if (IniFileName = '') IniFileName = DefaultExtension(ChangeFileName,'INI') ChangeFileName = LookForCtlFile(ChangeFileName) else if ChangeFileName > '' if Extension ChangeFileName = '' St = ForceExtension(ChangeFileName,'INI') if ExistFile St ChangeFileName = St else ChangeFileName = LookForCtlFile(ChangeFileName) endif endif endif endif #If McAfee if (Now >= TimeOf '07-01-2000') Help endif #Endif if not RestoreMode and (ChangeFileName = '') if (ParamStr(2) = '') Help else Error('File not Found: ' + CleanFileName(ParamStr(2))) endif endif StandardIO if RestoreMode then Return ;-- Duplicates List - Add your own duplicates here. HashLevel = 1 Hash('DEVICE=[386ENH]') = True if not Quiet then Writeln 'Processing Change File: ' ChangeFileName ' ...' SetupLibWords ProcessChangeFile Hash('ADD') = True Hash('ADDITEM') = True Hash('ADDITEMCOMMA') = True Hash('ADDVALUE') = True Hash('AFTER') = True Hash('APPENDLOG') = True Hash('BACKUPNAME') = True Hash('BEFORE') = True Hash('CHANGE') = True Hash('CLEANEMPTYSECTIONS') = True Hash('CLEANNOEQUALS') = True Hash('DEL') = True Hash('DELITEM') = True Hash('DELITEMCOMMA') = True Hash('DUPLICATES') = True Hash('FIRST') = True Hash('LOG') = True Hash('NOBACKUP') = True Hash('SUBST') = True Hash('TESTMODE') = True Hash('YAK') = True TestFreeMemory #If not MarxErrors ErrorLineName = ChangeFileName #Endif EndProc Procedure ResetVariables dispose(NameIndex) dispose(BlockStartIndex) dispose(BlockEndIndex) dispose(SubFind) dispose(SubReplace) dispose(SubFindG) dispose(SubReplaceG) dispose(GlobalDups) HashDisposeLevel(2) LogGroup = '' CurrentSection = 0 BackupName = '' BackupExtension = 'BNI' EndProc Procedure BackName if BackupName > '' then Return BackupName Return ForceExtension(IniFileName,BackupExtension) EndProc Procedure TestFileResult (Name) var Err if FileResult = 0 then Return if FileResult = 5 Error('File Access Error in ' + Name + ': Access Denied',0) else Error('File Access Error: ' + Str(FileResult) + ' in ' + Name,0) endif EndProc Procedure ProcessFile (Name) var FileList MultiFile X if InputRedirected and FirstProcessFile IniFileName = '' else IniFileName = DefaultExtension(Name,'INI') endif FirstProcessFile = False ReadTextFile(IniFileName,Orig) TestFreeMemory if NumberOfElements Orig > 0 ;- Loop Past Comments and blank lines X = 1 while (X < NumberOfElements(Orig)) and ((Orig[X] StartsWith ';') or (Orig[X] = '')) X = X + 1 endwhile if ExistFile(Orig[X]) MultiFile = True FileList = Orig Loop FileList if LoopVal StartsWith ';' then LoopVal = '' if LoopVal > '' if ExistFile(LoopVal) ProcessFile(LoopVal) endif endif EndLoop endif endif if not MultiFile if RestoreMode if ExistFile(BackName) Writeln 'Restoring ' IniFileName DelFile(ForceExtension(IniFileName,'BAK')) FileRename(IniFileName,ForceExtension(IniFileName,'BAK')) FileRename(BackName,IniFileName) TestFileResult(BackName) else Writeln BackName ' not Found!' endif else DsFileName = PathPart(IniFileName) + '\DS' + Str(NovConnection) DsFileName = CleanFileName(DsFileName + '.$$$') ResetVariables if not Quiet then Writeln 'Converting INI File: ' IniFileName ' ' NeedsIndexing ChangeFile RemoveExtraBlankLines if TestMode WriteTextFile(BackName,Orig) TestFileResult(BackName) else DelFile(BackName) FileRename(IniFileName,BackName) WriteTextFile(IniFileName,Orig) TestFileResult(IniFileName) endif if NoBackup and not TestMode DelFile(BackName) endif if Logging FileClose(LogHandle) Logging Off endif if Yak then Writeln endif endif ; Writeln(FreeMemory) EndProc Procedure Main Setup ProcessFile(IniFileName) EndProc