home *** CD-ROM | disk | FTP | other *** search
MarxMenu script | 1994-02-10 | 8.4 KB | 361 lines |
- Comment
- ==========================================================
-
- Computer Tyme IniDif * Copyright 1993 by Marc Perkel
- All Rights Reserved
-
- Computer Tyme * 411 North Sherman, Suite 300 * Springfield Mo. 65802
- (800) 548-5353 Sales * (417) 866-1222 Voice * (417) 866-1665 Data
-
- IniDif is a Windows *.INI file comparer. It is designed to assist the
- network administrator who has to maintain INI files for many users.
-
- USAGE: INIDIF NewFile OldFile ChangeFile
-
- Example:
- INIDIF SYSTEM.INI SYSTEM.OLD SYSTEM.CHG
-
- ==========================================================
- EndComment
-
- ;------ Create Variables
-
- var
- OrigFileName
- Orig
- UOrig
- NewFileName
- New
- UNew
- ChangeFileName
- Changes
- Match
- NameIndex
- BlockStartIndex
- BlockEndIndex
- ThisSection
- LastSection
- LastSectionNumber
- DriversSection
-
-
- Main
-
- ;======================= P R O C E D U R E S ===========================
-
- Comment
- ================================================
-
- The file is read into the array Orig. It is then processed and a
- parallel array UOrig is created. The lines in UOrig are upper case with
- extra spaces and comments removed and are more suitable for searching
- and comparing.
-
- NameIndex contains a list of group headings. BlockStartIndex contains a list
- of line numbers that groups start. BlockEndIndex contains a list og line
- numbers where groups end. That way when I search I know what range of
- line numbers to start and end at.
-
- ================================================
- EndComment
-
-
- Procedure IndexFile
- var LastTextLine NotFirst
- UOrig = Orig
- Loop UOrig
- LoopVal = ProcessLine(LoopVal)
- EndLoop
- Loop UOrig
- if Left(LoopVal,1) = '['
- AppendArray(NameIndex,LoopVal)
- AppendArray(BlockStartIndex,LoopIndex)
- if NotFirst
- AppendArray(BlockEndIndex,LastTextLine)
- else
- NotFirst = True
- endif
- endif
- if LoopVal > '' then LastTextLine = LoopIndex
- EndLoop
- AppendArray(BlockEndIndex,LastTextLine)
- EndProc
-
- ;----- New Original line to uppercase and removes comment lines
-
- Procedure ProcessLine (St)
- var P
- Trim(St)
- if Left(St,1) = ';'
- St = ''
- elseif Left(St,1) = '#'
- St = ''
- else
- St = UpperCase(St)
- endif
- P = pos('=',St)
- if P > 0
- P = P + 1
- while Mid(St,P,1) = ' '
- delete(St,P,1)
- endwhile
- P = P - 2
- while (Mid(St,P,1) = ' ') and (P > 0)
- delete(St,P,1)
- P = P - 1
- endwhile
- endif
- Return St
- EndProc
-
-
- Procedure SectionName
- if ThisSection = 0 then Return ''
- Return NameIndex[ThisSection]
- EndProc
-
-
- Procedure FindSection (St)
- ThisSection = PosInList(St,NameIndex)
- if ThisSection = 0
- DriversSection = False
- else
- DriversSection = St = '[386ENH]'
- Match[BlockStartIndex[ThisSection]] = True
- endif
- EndProc
-
-
- Procedure FindLine (St)
- var S E KeyWord
- if ThisSection = 0 then Return 0
- KeyWord = Left(St,pos('=',St))
-
- ;- The [386Enh] section is a special case if adding drivers
-
- if DriversSection
- if KeyWord = 'DEVICE='
- KeyWord = St
- endif
- endif
-
- S = BlockStartIndex[ThisSection]
- E = BlockEndIndex[ThisSection]
-
- if DriversSection
-
- while S <= E
- if pos(KeyWord,UOrig[S]) > 0
- Match[S] = True
- Return S
- endif
- S = S + 1
- endwhile
-
- else
-
- while S <= E
- if Left(UOrig[S],length(KeyWord)) = KeyWord
- Match[S] = True
- Return S
- endif
- S = S + 1
- endwhile
-
- endif
- Return 0
- EndProc
-
-
- Procedure Log (St)
- AppendArray(Changes,St)
- EndProc
-
-
- Procedure CheckForDelete (Section)
- var S E
- if Section = 0 then Return
- S = BlockStartIndex[Section] + 1
- E = BlockEndIndex[Section]
-
- while S <= E
- if not Match[S]
- if UOrig[S] > '' then Log('DEL ' + Orig[S])
- endif
- S = S + 1
- endwhile
- EndProc
-
-
- Procedure CheckForDeleteSections
- Loop BlockStartIndex
- if LoopVal > 0
- if BlockEndIndex[LoopIndex] > 0
- if not Match[LoopVal]
- Log ''
- Log('DEL ' + Orig[LoopVal])
- endif
- endif
- endif
- EndLoop
- EndProc
-
-
- Procedure LogChange (St)
- if SectionName <> LastSection
- if LastSection <> ''
- CheckForDelete(LastSectionNumber)
- Log ''
- endif
- if BlockEndIndex[ThisSection] = 0
- Log New[BlockStartIndex[ThisSection]]
- else
- Log Orig[BlockStartIndex[ThisSection]]
- endif
- LastSection = SectionName
- LastSectionNumber = ThisSection
- endif
- if St > '' then Log St
- EndProc
-
-
- Procedure CompareFiles
- var St Line Del AddMode ChangeMode Line Tmp
- Loop New
- St = UNew[LoopIndex]
- if St > ''
- if Left(St,1) = '['
-
- ;- New Group
-
- FindSection(St)
- if ThisSection = 0
- AppendArray(NameIndex,St)
- AppendArray(BlockStartIndex,LoopIndex)
- AppendArray(BlockEndIndex,0)
- ThisSection = NumberOfElements(NameIndex)
- endif
- else
- Line = FindLine(St)
- if Line = 0
- LogChange LoopVal
- else
- if LoopVal <> Orig[Line]
- LogChange LoopVal
- endif
- endif
- endif
- endif
- EndLoop
- CheckForDelete(LastSectionNumber)
- CheckForDeleteSections
- EndProc
-
-
- Procedure Help
- Writeln 'Computer Tyme INIDIF * Copyright 1993 by Marc Perkel'
- Writeln 'All Rights Reserved * Version 1.2 * Release Date: 11-29-93'
-
- Include 'ADDRESS.INC'
-
- Writeln 'INIDIF compares two INI files and produces a third file that contains'
- Writeln 'the differences between the two INI files. This allows you to install'
- Writeln 'a new windows program and compare the changed INI file to the original'
- Writeln 'INI file. The change file can then be used with INITYME to apply the same'
- Writeln 'changes to other INI files of other users on a network.'
- Writeln
- Writeln 'USAGE: INIDIF NewFile OldFile ChangeFile'
- Writeln
- Writeln 'Example:'
- Writeln ' INIDIF SYSTEM.INI SYSTEM.OLD SYSTEM.CHG'
- Writeln
- Writeln 'INIDIF is licensed for $35/User, $95/fileserver, $995 site license.'
- Writeln 'INITYME comes free with INIDIF.'
- ExitMenu
- EndProc
-
-
- Procedure Beg
- var Jessica
- BoxHeader ' * Shameless Beg Screen * '
- DrawBox 10 8 61 7
- Writeln
- WriteCenter '* IniDif Evaluation Copy *'
- Writeln
- WriteCenter 'Please remember to register this software.'
- Writeln
- if Timer and 1 = 0
- Jessica = Now - TimeOf('1-17-80') / SecondsInDay / 365 + 2
- WriteCenter 'I have a ' Jessica ' year old daughter who wants to go shopping.'
- else
- WriteCenter "I'd sure hate to have to find a real job."
- endif
- Wait 600
- EraseTopWindow
- ClearKbdBuffer
- EndProc
-
-
- Procedure AddIniExtension (Name)
- Name = UpperCase(Name)
- if pos('.',Name) > 0 then Return Name
- Return ForceExtension(Name,'INI')
- EndProc
-
-
- Procedure Setup
- BoxBorderColor Green Blue
- BoxInsideColor White Blue
- BoxHeaderColor Yellow Mag
- ;Beg
- StandardIO
- Writeln
- ExitCode = 0
- NewFileName = AddIniExtension(ParamStr(2))
- OrigFileName = AddIniExtension(ParamStr(3))
- ChangeFileName = AddIniExtension(ParamStr(4))
- if (ChangeFileName = '') or not ExistFile(NewFileName) or not ExistFile(OrigFileName)
- Help
- endif
- Write 'Reading Files ... '
- ReadTextFile(NewFileName,New)
- UNew = New
- Loop UNew
- LoopVal = ProcessLine(LoopVal)
- EndLoop
- EndProc
-
-
- Procedure ResetVariables
- dispose(NameIndex)
- dispose(BlockStartIndex)
- dispose(BlockEndIndex)
- ThisSection = 0
- EndProc
-
-
- Procedure ProcessFile
- var FileList
- ReadTextFile(OrigFileName,Orig)
- if NumberOfElements(Orig) = 0 then Return
- ResetVariables
- Log('; Changes to turn ' + OrigFileName + ' into ' + NewFileName)
- Log('; File created: ' + DateString + ' ' + TimeString)
- Log ''
- Writeln
- Write 'Comparing Files ... '
- IndexFile
- CompareFiles
- Writeln
- Write 'Writing Changes ... '
- WriteTextFile(ChangeFileName,Changes)
- Writeln
- Writeln 'Done!'
- EndProc
-
-
- Procedure Main
- Setup
- ProcessFile
- EndProc
-