Category : Network Files
Archive   : NSK.ZIP
Filename : INITYME.MNU

 
Output of file : INITYME.MNU contained in archive : NSK.ZIP
Comment
==========================================================

Computer Tyme IniTyme * 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

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.INI SYSTEM.INI

==========================================================
EndComment

;------ Create Variables

var
Orig
UOrig
Changes
UChanges
NameIndex
BlockStartIndex
BlockEndIndex
ThisSection
SubFind
SubReplace
SubFindG
SubReplaceG
GroupMode
GroupSection
DriversSection
Log
Logging
LogFileName
LogGroup
BackName
RestoreMode
TestMode

var
IfArray
Stack
GotoList
LibList
LibProcList
IfLine
GroupList
ParenLevel

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
if NumberOfElements(BlockStartIndex) > 0
AppendArray(BlockEndIndex,LastTextLine)
endif
EndProc

;----- When adding or deleting the BlockStartIndex must be updated

Procedure AdjustLineIndex (Line, Adj)
Loop BlockStartIndex
if Line <= LoopVal
LoopVal = LoopVal + Adj
endif
EndLoop
Loop BlockEndIndex
if Line <= LoopVal
LoopVal = LoopVal + Adj
endif
EndLoop
EndProc

;----- Changes Original line to uppercase and removes comment lines

Procedure ProcessLine (St)
var P St2
St = EnvExpandString(St)
Trim(St)
if Left(St,1) = ';'
St = ''
elseif Left(St,1) = '#'
St = ''
else
St = UpperCase(St)
endif

;-- Trim spaces around = sign

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 LogEvent (St)
if not Logging then Return
if LogGroup <> SectionName
if LogGroup <> ''
AppendArray(Log,'')
endif
AppendArray(Log,SectionName)
LogGroup = SectionName
endif
AppendArray(Log,St)
EndProc


;----- Change a line, 0 for line number adds line

Procedure ChangeOrAddLine (St,Line)
if Line = 0
if ThisSection > 0
Line = BlockEndIndex[ThisSection] + 1
ArrayInsert(Orig,Line,1)
ArrayInsert(UOrig,Line,1)
Orig[Line] = St
UOrig[Line] = ProcessLine(St)
AdjustLineIndex(Line - 1,1)
LogEvent(' Added: ' + St)
endif
else
if St <> Orig[Line]
LogEvent(' Changed: ' + Orig[Line] + ' to ' + St)
Orig[Line] = St
UOrig[Line] = ProcessLine(St)
endif
endif
EndProc


Procedure DelLine (Line)
if Line = 0 then Return
LogEvent(' Deleted: ' + Orig[Line])
Delete(Orig,Line,1)
Delete(UOrig,Line,1)
AdjustLineIndex(Line,-1)
EndProc


Procedure FindSection (St)
ThisSection = PosInList(St,NameIndex)
if ThisSection = 0
GroupSection = False
DriversSection = False
else
GroupSection = St = '[GROUPS]'
DriversSection = St = '[386ENH]'
endif
EndProc


Procedure AddSection (St)
var Lines Proc
Proc = ProcessLine(St)

;- Add a blank line

AppendArray(Orig,'')
AppendArray(UOrig,'')

;- Add ThisSection header

AppendArray(Orig,St)
AppendArray(UOrig,Proc)

;- Update Indexes

Lines = NumberOfElements(UOrig)
AppendArray(NameIndex,Proc)
AppendArray(BlockStartIndex,Lines)
AppendArray(BlockEndIndex,Lines)

;- Make new ThisSection the current ThisSection

ThisSection = NumberOfElements(NameIndex)

if Logging
LogGroup = UpperCase(St)
AppendArray(Log,'')
LogEvent('Added: ' + LogGroup)
endif

EndProc


Procedure DelSection (St)
var S E D
FindSection(St)
if ThisSection = 0 then Return
S = BlockStartIndex[ThisSection]
if ThisSection < NumberOfElements(BlockStartIndex)
E = BlockStartIndex[ThisSection + 1]
else
E = NumberOfElements(UOrig)
endif
D = E - S
delete(Orig,S,D)
delete(UOrig,S,D)
delete(NameIndex,ThisSection,1)
delete(BlockStartIndex,ThisSection,1)
delete(BlockEndIndex,ThisSection,1)
AdjustLineIndex(S,0 - D)
ThisSection = 0

if Logging
LogGroup = ''
AppendArray(Log,'')
LogEvent('Deleted: ' + UpperCase(St))
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

;- The [Groups] section of ProgMan.INI is a special case

GroupMode = GroupSection and (Left(St,5) = 'GROUP')

if GroupMode
delete(St,1,pos('=',St))
KeyWord = FilePart(St)
endif

S = BlockStartIndex[ThisSection]
E = BlockEndIndex[ThisSection]

if GroupMode or DriversSection

while S <= E
if pos(KeyWord,UOrig[S]) > 0
Return S
endif
S = S + 1
endwhile

else

while S <= E
if Left(UOrig[S],length(KeyWord)) = KeyWord
Return S
endif
S = S + 1
endwhile

endif
Return 0
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
P = Pos(LoopVal,UOrig[S])
if P > 0
St = Orig[S]
delete(St,P,Length(LoopVal))
insert(SubR[LoopIndex],St,P)
ChangeOrAddLine(St,S)
endif
EndLoop
S = S + 1
endwhile
dispose(SubFind)
dispose(SubReplace)
EndProc


Procedure ApplySubst
if ThisSection = 0 then Return
ApplySubstBlock(SubFind,SubReplace,BlockStartIndex[ThisSection],BlockEndIndex[ThisSection])
EndProc


Procedure NextGroup
var X S E St Match
X = 1
repeat
S = BlockStartIndex[ThisSection]
E = BlockEndIndex[ThisSection]
Match = False
while (S <= E) and not Match
St = 'GROUP' + Str(X)
Match = pos(St,UOrig[S]) > 0
S = S + 1
endwhile
if not Match then Return X
X = X + 1
until False
EndProc


Procedure RemoveExtraBlankLines
var Tmp
Trim(Orig)
Tmp = Orig
dispose Orig
Loop Tmp
if (LoopVal > '') or (Tmp[LoopIndex + 1] > '')
AppendArray(Orig,LoopVal)
endif
EndLoop
EndProc



Procedure RightOfEqual (St)
var B St2
B = pos('=',St)
if B > 0
St2 = Mid(St,succ(B),255)
trim(St2)
Return St2
else
Return ''
endif
EndProc


Procedure AddItem (Line)
var St List New UNew NewLine Next UNext
St = UOrig[Line]
New = RightOfEqual(Changes[LoopIndex])
UNew = RightOfEqual(UChanges[LoopIndex])
St = RightOfEqual(St)
NewLine = Orig[Line]
while St > ''
AppendArray(List,NextWord(St))
endwhile
while UNew > ''
Next = NextWord(New);
UNext = NextWord(UNew);
if PosInList(UNext,List) = 0
NewLine = NewLine + ' ' + Next
endif
endwhile
ChangeOrAddLine(NewLine,Line)
EndProc


Procedure DelItem (Line)
var St List New UNew NewLine Next UNext P
St = UOrig[Line]
UNew = RightOfEqual(UChanges[LoopIndex])
St = St + ' '
NewLine = Orig[Line]
while UNew > ''
UNext = NextWord(UNew);
P = pos(UNext + ' ',St)
if P > 0
delete(St,P,length(UNext) + 1)
delete(NewLine,P,length(UNext) + 1)
endif
endwhile
ChangeOrAddLine(NewLine,Line)
EndProc


Procedure ChangeFile
var St Line Del AddMode ChangeMode Line Tmp
Loop Changes
St = UChanges[LoopIndex]
if St > ''

if ThisSection = 0
if St = 'TESTMODE'
TestMode

elseif Left(St,3) = 'LOG'
Tmp = NextWord(St)
LogFileName = NextWord(St)
if LogFileName = ''
LogFileName = ForceExtension(BackName,'LOG')
endif
Logging

endif
endif

Del = Left(St,4) = 'DEL '
if Del
delete(St,1,4)
Trim(St)
endif

AddMode = Left(St,4) = 'ADD '
if AddMode
delete(St,1,4)
Trim(St)
delete(LoopVal,1,4)
Trim(LoopVal)
endif

ChangeMode = Left(St,7) = 'CHANGE '
if ChangeMode
delete(St,1,7)
Trim(St)
delete(LoopVal,1,7)
Trim(LoopVal)
endif

if Left(St,8) = 'ADDITEM '
delete(St,1,8)
Trim(St)
delete(LoopVal,1,8)
Trim(LoopVal)
Line = FindLine(St)
if Line > 0
AddItem(Line,St)
St = ''
endif
endif

if Left(St,8) = 'DELITEM '
delete(St,1,8)
Trim(St)
delete(LoopVal,1,8)
Trim(LoopVal)
Line = FindLine(St)
if Line > 0
DelItem(Line,St)
endif
St = ''
endif

if Left(St,6) = 'SUBST '
St = Changes[LoopIndex]
delete(St,1,6)
Trim(St)
if ThisSection = 0
AppendArray(SubFindG,ProcessLine(NextWord(St)))
AppendArray(SubReplaceG,NextWord(St))
else
AppendArray(SubFind,ProcessLine(NextWord(St)))
AppendArray(SubReplace,NextWord(St))
endif
St = ''
endif

if St > ''
if Left(St,1) = '['

;- New Group

ApplySubst
if Del
DelSection(St)
else
FindSection(St)
if ThisSection = 0
AddSection(LoopVal)
endif
endif
else
Line = FindLine(St)

if Del
DelLine(Line)
else

;- Groups in Progman

if GroupMode
if Line > 0
Tmp = Left(Orig[Line],pos('=',Orig[Line]))
else
Tmp = 'Group' + Str(NextGroup) + '='
endif
delete(LoopVal,1,pos('=',LoopVal))
insert(Tmp,LoopVal,1)
endif

if AddMode
if Line = 0
ChangeOrAddLine(LoopVal,0)
endif
else
if not ChangeMode or (Line > 0)
ChangeOrAddLine(LoopVal,Line)
endif
endif

endif
endif
endif
endif
IfLine = IfArray[LoopIndex]
Interpret
if NumberOfElements Stack <> 0
Error ('Too Many Parameters!',LoopIndex)
endif
EndLoop
ApplySubst
ApplySubstBlock(SubFindG,SubReplaceG,1,NumberOfElements(Orig))
EndProc


Procedure Help
var Help HelpFile
HelpFile = ExistOnPath 'INITYME.HLP'
if HelpFile = ''
Writeln
Writeln 'IniTyme * Copyright 1993 by Marc Perkel'

Include 'ADDRESS.INC'

Writeln 'Missing file INITYME.HLP'
else
BoxHeader ' Viewing ' + HelpFile + ' '
DrawBox 1 1 ScreenWidth ScreenHeight
ViewTextFile(HelpFile)
endif
ExitMenu
EndProc


Procedure Beg
var Jessica
BoxHeader ' * Shameless Beg Screen * '
DrawBox 10 8 61 7
Writeln
WriteCenter '* IniTyme 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 Error (St,Line)
Writeln
if Line > 0
Writeln 'IniTyme Error in line ' Line
Writeln St
else
Writeln 'IniTyme Error: ' St
endif
ExitMenu
EndProc


;----- INITYME.INC has the conditional logic.

Include 'INITYME.INC'


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
RestoreMode = UpperCase(ParamStr(2)) = 'RESTORE'
if not RestoreMode
if (ParamStr(2) = '') or not ExistFile(AddIniExtension(ParamStr(2)))
Help
endif
endif
StandardIO
if NovConnection > 0
NovGroups(GroupList)
SortArray(GroupList)
endif

ReadTextFile(AddIniExtension(ParamStr(2)),Changes)
Loop Changes
Trim(LoopVal)
LoopVal = EnvExpandString(LoopVal)
EndLoop
UChanges = Changes
Loop UChanges
LoopVal = ProcessLine(LoopVal)

if Left(LoopVal,3) = 'IF '
IfArray[LoopIndex] = LoopVal
LoopVal = ''
Changes[LoopIndex] = ''
PushStack(LoopIndex)

elseif Left(LoopVal,5) = 'ENDIF'
LoopVal = ''
Changes[LoopIndex] = ''
GotoList[PopStack] = LoopIndex

elseif Left(LoopVal,4) = '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

SetupLibWords
EndProc


Procedure ResetVariables
dispose(NameIndex)
dispose(BlockStartIndex)
dispose(BlockEndIndex)
dispose(SubFind)
dispose(SubReplace)
dispose(SubFindG)
dispose(SubReplaceG)
dispose(Log)
LogGroup = ''
ThisSection = 0
EndProc


Procedure ProcessFile (Name)
var FileList MultiFile
Name = AddIniExtension(Name)
BackName = ForceExtension(Name,'BNI')
ReadTextFile(Name,Orig)
if NumberOfElements(Orig) > 0
if ExistFile(Orig[1])
MultiFile = True
FileList = Orig
Loop FileList
ProcessFile(LoopVal)
EndLoop
else
if RestoreMode
if ExistFile(BackName)
Writeln 'Restoring ' Name
DelFile(Name)
FileRename(BackName,Name)
else
Writeln BackName ' not Found!'
endif
else
ResetVariables
Write 'Converting: ' Name ' '
IndexFile
ChangeFile
RemoveExtraBlankLines

if TestMode
WriteTextFile(BackName,Orig)
else
DelFile(BackName)
FileRename(Name,BackName)
WriteTextFile(Name,Orig)
endif

if Logging
Trim(Log)
WriteTextFile(LogFileName,Log)
endif

Writeln 'Done!'
endif
endif
endif
EndProc


Procedure Main
; TestMode
Setup
ProcessFile(ParamStr(3))
EndProc


  3 Responses to “Category : Network Files
Archive   : NSK.ZIP
Filename : INITYME.MNU

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/