home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 5 Edit
/
05-Edit.zip
/
ted99107.zip
/
TextEdit.CMD
next >
Wrap
OS/2 REXX Batch file
|
1999-04-17
|
43KB
|
1,670 lines
/*
* Generator : PPWIZARD version 99.106
* : FREE tool for OS/2, Windows, DOS and UNIX by Dennis Bareis (db0@anz.com)
* : http://www.labyrinth.net.au/~dbareis/ppwizard.htm
* Time : Saturday, 17 Apr 1999 9:14:25am
* Input File : E:\DB\PROJECTS\OS2\textedit\TEXTEDIT.x
* Output File : .\OUT\TextEdit.CMD
*/
/*
*$Header:E:/DB/PVCS.IT/OS2/TEXTEDIT/TEXTEDIT.X_V 1.5 17 Apr 1999 08:54:12 Dennis_Bareis $/PLATFORM/TEXTEDIT.X_V 1.5 11 Oct 1996 16:40:40 Dennis_Bareis $/PLATFORM/TEXTEDIT.X_V 1.4 11 Oct 1996 16:26:28 Dennis_Bareis $/PLATFORM/TEXTEDIT.X_V 1.3 17 Sep 1996 10:51:38 Dennis_Bareis $
*/
PgmVersion="99.107"
CopyRightDisplayed='N'
LimitDefines=''
TabChar=d2c(9)
trace off
call RemoveColorCodes
/*
*$Header:E:/DB/PVCS.IT/OS2/TEXTEDIT/SAYIT.XHV 1.1 25 Jul 1998 16:04:10 Dennis_Bareis $
*/
if translate(strip(arg(1)))='DEBUG' then
call DisplayCopyright
/*
*REXSYSTM.XH Version 99.092 By Dennis Bareis
*http://www.labyrinth.net.au/~dbareis/index.htm(db0@anz.com)
*/
parse version RexVersionInfo
if pos('REGINA',translate(RexVersionInfo))<>0 then
RexWhich='REGINA'
else
RexWhich='STANDARD_OS/2'
parse source RexSystemOpSys .
if RexSystemOpSys="WIN32" then
do
parse value uname()with RexSystemOpSys .
if RexSystemOpSys<> "WIN95" & RexSystemOpSys <> "WIN98" & RexSystemOpSys <> "WINNT" then
do
call RexSystemFailure 'Regina uname() returned "' || uname() || '" (expected WIN95, WIN98 or WINNT)'
end
end
RexSystmRexxPgmName='?';RexSystmRexxPgmName=RexGetFullSourceName()
if arg(2)<> '' then
call RexSystemFailure 'ARG(2) contains unexpected data of ' || arg(2) || '.'
if translate(strip(arg(1)))='DEBUG' then
do
call RexDumpSystemInfo
exit(0)
end
if RexWhich='STANDARD_OS/2' then
do
call SetLocal
RexEnvVarPool='OS2ENVIRONMENT'
RexStdoutStream='STDOUT'
RexStderrStream='STDERR'
end
else
do
OPTIONS 'NOEXT_COMMANDS_AS_FUNCS'
numeric digits 11
RexEnvVarPool='SYSTEM'
RexStdoutStream='<stdout>'
RexStderrStream='<stderr>'
end
if RexSystemOpSys<> "UNIX" then
do
RexDirChar='\'
RexOptionChar='/'
end
else
do
RexDirChar='/'
RexOptionChar='-'
end
signal EndREXSYSTMXh
RexDumpSystemInfo:
say 'Program Name : ' ||RexSystmRexxPgmName
say 'Op System : ' ||RexSystemOpSys
say 'Rexx Ver : ' ||RexVersionInfo
say 'Which System : ' ||RexWhich
if RexWhich='REGINA' then
say 'regina uname(): ' ||uname()
return
RexNeedReginaWorkAround:
if RexWhich='STANDARD_OS/2' then
return('N')
else
return('Y')
RexGetFullSourceName:
parse source . . TmpRexxSrc
if RexWhich='REGINA' then
TmpRexxSrc=stream(strip(TmpRexxSrc), 'c', 'query exists')
if TmpRexxSrc='' then
call RexSystemFailure 'Could not determine the name of the rexx program!'
return(TmpRexxSrc)
RexQueryExists:
return(stream(arg(1), 'c', 'query exists'))
RexGetNameOfTmpDir:
TmpDir=GetEnv('TMP')
if TmpDir='' then
TmpDir=GetEnv('TEMP')
if TmpDir='' then
do
if RexSystemOpSys="UNIX" then
TmpDir='/tmp'
end
return(TmpDir)
Stderr2:
if RexSystemOpSys="DOS" | RexSystemOpSys = "WIN95" | RexSystemOpSys = "WIN98" then
return('')
else
return(' 2>' ||arg(1))
AddressCmd:
SysCmd2Exec=arg(1)
if RexWhich='STANDARD_OS/2' then
SysCmd2Exec='@' ||SysCmd2Exec
SysCmd2Exec
SysCmdRc=Rc
return(SysCmdRc)
_SysFileDelete:
if RexSystemOpSys="DOS" | RexSystemOpSys = "WIN95" | RexSystemOpSys = "WIN98" then
return(AddressCmd('if exist ' || arg(1) || ' del ' || arg(1) || ' >nul'))
else
do
if RexSystemOpSys="UNIX" then
return(AddressCmd('rm -f ' || arg(1) || ' >& /dev/null'))
else
return(AddressCmd('del ' || arg(1) || ' >nul' || Stderr2('&1')))
end
GetEnv:
return(value(arg(1),,RexEnvVarPool))
EndREXSYSTMXh:
PpWizardPgmName=RexSystmRexxPgmName
PpWizardOpSys=RexSystemOpSys
if RexSystemOpSys="OS/2" then
call SetColorCodes
else
call RemoveColorCodes
signal on NOVALUE name RexxTrapUninitializedVariable
signal on SYNTAX name RexxTrapSyntaxError
call DisplayCopyright
Parameters=arg(1)
parse var Parameters TextFile TextFileOut ChangeFile Parameters
if ChangeFile="" then
UserSyntaxError("Too few parameters")
if stream(TextFile, 'c', 'query exists') == '' then
do
say LightRed|| 'ERROR: The text input file "' || TextFile || '" does not exist....' ||Reset
exit(60)
end
if stream(ChangeFile, 'c', 'query exists') == '' then
do
say LightRed|| 'ERROR: The change file "' || ChangeFile || '" does not exist....' ||Reset
exit(65)
end
LineBeingProcessed=''
LineSourceBeingProcessed=''
LongestSourceInfo=0
LinesWithTabsFound=0
CmtLine=';'
CmtInline='//'
CmtLineLng=length(CmtLine)
/*
*$Header:E:/DB/PVCS.IT/OS2/TEXTEDIT/LOADFILE.XHV 1.2 17 Apr 1999 08:54:06 Dennis_Bareis $
*/
signal EndLoadFile
IoError:
FileState=stream(arg(1), 'State')
if FileState='READY' then
return('NO')
return(stream(arg(1), 'Description'))
LoadTextFile:
TextFileName=arg(1)
AbsoluteTextFileName=stream(TextFileName, 'c', 'query exists')
say ' * Text File : ' ||TextFileName
if AbsoluteTextFileName='' then
return(52)
if translate(AbsoluteTextFileName)<>translate(TextFileName)then
do
TextFileName=AbsoluteTextFileName
say ' * Its FullName: ' ||TextFileName
end
TextFile.0=0
CloseRc=stream(TextFileName, 'c', 'close')
LinesRead=0
do while lines(TextFileName)<>0
ThisLine=linein(TextFileName)
LinesRead=LinesRead+1
TextFile.LinesRead=ThisLine
end
TextFile.0=LinesRead
if IoError(TextFileName)='NO' then
LoadRc=0
else
LoadRc=83
CloseRc=stream(TextFileName, 'c', 'close')
return(LoadRc)
LoadChangeFile:
if IncludeLevel=0 then
do
TotalChangeLineNumber=0
ChangeFile.0=0
end
ChangeFile.File.IncludeLevel=arg(1)
say copies(" ", IncludeLevel) || ' * Change File : ' ||ChangeFile.File.IncludeLevel
AbsoluteTextFileName=stream(ChangeFile.File.IncludeLevel, 'c', 'query exists')
if AbsoluteTextFileName=="" then
do
say 'ERROR: File "' || ChangeFile.File.IncludeLevel || '" does not exist!'
return(113)
end
if translate(AbsoluteTextFileName)<>translate(ChangeFile.File.IncludeLevel)then
do
ChangeFile.File.IncludeLevel=AbsoluteTextFileName
say copies(" ", IncludeLevel) || ' * Its FullName: ' ||AbsoluteTextFileName
end
ChangeFile.LineNumber.IncludeLevel=0
LinesProcessed.IncludeLevel=0
do while lines(ChangeFile.File.IncludeLevel)>0
StrippedFileLine=strip(linein(ChangeFile.File.IncludeLevel))
ChangeFile.LineNumber.IncludeLevel=ChangeFile.LineNumber.IncludeLevel+1
if StrippedFileLine="" then
iterate
if pos(TabChar,StrippedFileLine)<>0 then
LinesWithTabsFound=LinesWithTabsFound+1
parse var StrippedFileLine HashInclude IncludeFileName
if translate(HashInclude)='#INCLUDE' then
do
IncludeFileName=ReplaceHashAndStandardDefines(strip(IncludeFileName))
if IncludeFileName="" then
do
say 'ERROR: No filename specified on #include statement!'
return(164)
end
MaybeQuote=left(IncludeFileName,1)
if MaybeQuote='"' | MaybeQuote = "<" then
do
if MaybeQuote='"' then
ExpectAtEnd='"'
else
ExpectAtEnd='>'
if right(IncludeFileName,1)<>ExpectAtEnd then
do
say 'ERROR: Incorrectly quoted filename of "' || IncludeFileName || '" specified on #include line!'
return(180)
end
IncludeFileName=substr(IncludeFileName,2,length(IncludeFileName)-2)
end
IncludeLevel=IncludeLevel+1
IncludeRc=LoadChangeFile(IncludeFileName)
IncludeLevel=IncludeLevel-1
if IncludeRc=0 then
iterate
else
do
call Stream ChangeFile.File.IncludeLevel, 'c', 'Close'
return(IncludeRc)
end
end
TotalChangeLineNumber=TotalChangeLineNumber+1
ChangeFile.TotalChangeLineNumber=StrippedFileLine
ChangeFile.SourceInfo.TotalChangeLineNumber=ChangeFile.File.IncludeLevel|| '(' || ChangeFile.LineNumber.IncludeLevel || ')'
if length(ChangeFile.SourceInfo.TotalChangeLineNumber)>LongestSourceInfo then
LongestSourceInfo=length(ChangeFile.SourceInfo.TotalChangeLineNumber)
end
if IoError(ChangeFile.File.IncludeLevel)='NO' then
LoadRc=0
else
LoadRc=211
call Stream ChangeFile.File.IncludeLevel, 'c', 'Close'
ChangeFile.0=TotalChangeLineNumber
return(LoadRc)
EndLoadFile:
/*
*$Header:E:/DB/PVCS.IT/OS2/TEXTEDIT/HASHIF.XHV 1.0 13 May 1998 21:50:34 Dennis_Bareis $
*/
IfNesting=0
IfState.WantLines.0='Y'
IfState.IfTrue.0='Y'
IfState.InTrue.0='Y'
signal EndHashIf
WantLine:
if IfNesting=0 then
return('Y')
if IfState.WantLines.IfNesting='N' then
return('N')
else
do
if IfState.IfTrue.IfNesting=IfState.InTrue.IfNesting then
return('Y')
else
return('N')
end
ProcessHashIf:
TestCondition=arg(1)
WantTheLines=WantLine()
if WantTheLines='N' then
IfResult='N'
else
do
call SayIfDebugOn 'COMMAND: #if ' ||TestCondition
interpret 'IfResult = (' || strip( TestCondition ) || ')'
if IfResult then
IfResult='Y'
else
IfResult='N'
if IfResult='Y' then
call SayIfDebugOn ' #if: True'
else
call SayIfDebugOn ' #if: False'
end
IfNesting=IfNesting+1
IfState.WantLines.IfNesting=WantTheLines
IfState.InTrue.IfNesting='Y'
IfState.IfTrue.IfNesting=IfResult
return('OK')
ProcessHashElse:
if IfNesting=0 then
return("Found #elseif without matching #if")
if IfState.InTrue.IfNesting='N' then
return("Found unexpected #elseif (duplicated #elseif?)")
IfState.InTrue.IfNesting='N'
return('OK')
ProcessHashEndif:
if IfNesting=0 then
return("Found #endif without matching #if")
IfNesting=IfNesting-1
return('OK')
EndHashIf:
/*
*$Header:E:/DB/PVCS.IT/OS2/TEXTEDIT/DEFINE.XHV 1.2 09 Mar 1999 17:38:10 Dennis_Bareis $
*/
HashDefineCount=0
G.StdVar.CurrentPosn=0
G.StdVar.LastRc=0
G.StdVar.LastRcReason=""
G.StdVar.SyntaxError=0
G.StdVar.TextFileIn=TextFile
G.StdVar.TextFileOut=TextFileOut
G.StdVar.ChangeFile=ChangeFile
G.StdVar.Parameters=strip(Parameters)
G.StdVar.ReplaceCount=0
signal EndDefine
HashDefineExists:
do DefineIndex=1 to HashDefineCount
if arg(1)=DefineVariable.DefineIndex then
return(DefineIndex)
end
return('N')
AddHashDefine:
DefineVariable='{' || arg(1) || '}'
DefineContents=arg(2)
if pos(DefineVariable,DefineContents)<>0 then
do
say 'ERROR: #define of "' || DefineVariable || '" would cause infinite loop!'
return(76)
end
ItExists=HashDefineExists(DefineVariable)
if ItExists<> 'N' then
do
SaveIndex=ItExists
end
else
do
HashDefineCount=HashDefineCount+1
SaveIndex=HashDefineCount
end
DefineVariable.SaveIndex=DefineVariable
DefineContents.SaveIndex=DefineContents
return(0)
ReplaceHashAndStandardDefines:
HashDefineString=arg(1)
TotalChanges=0
if LimitDefines='' then
SearchAndReplaceUserDefines='Y'
else
do
if pos(LimitDefines,HashDefineString)=0 then
SearchAndReplaceUserDefines='N'
else
SearchAndReplaceUserDefines='Y'
end
if SearchAndReplaceUserDefines='Y' then
do
do until ChangeCount=0
ChangeCount=0
do DefineIndex=1 to HashDefineCount
HashDefineString=ReplaceString(HashDefineString,DefineVariable.DefineIndex,DefineContents.DefineIndex, "ChangeCount")
end
TotalChanges=TotalChanges+ChangeCount
end
end
HashDefineString=ReplaceStandardDefinitions(HashDefineString, "TotalChanges")
if arg(2)<> '' then
call value arg(2),TotalChanges
return(HashDefineString)
ReplaceStandardDefinitions:
DefineString=arg(1)
if(pos("${",DefineString)<>0)then
do
DefineString=ReplaceString(DefineString, "${CurrentPosn}",G.StdVar.CurrentPosn,arg(2))
DefineString=ReplaceString(DefineString, "${RcReason}",G.StdVar.LastRcReason,arg(2))
DefineString=ReplaceString(DefineString, "${Rc}",G.StdVar.LastRc,arg(2))
DefineString=ReplaceString(DefineString, "${ReplaceCount}",G.StdVar.ReplaceCount,arg(2))
if(pos("${",DefineString)<>0)then
do
DefineString=ReplaceString(DefineString, "${TextFileIn}",G.StdVar.TextFileIn,arg(2))
DefineString=ReplaceString(DefineString, "${TextFileOut}",G.StdVar.TextFileOut,arg(2))
DefineString=ReplaceString(DefineString, "${ChangeFile}",G.StdVar.ChangeFile,arg(2))
DefineString=ReplaceString(DefineString, "${Parameters}",G.StdVar.Parameters,arg(2))
if(pos("${",DefineString)<>0)then
do
DefineString=ReplaceString(DefineString, "${SyntaxErrorCount}",G.StdVar.SyntaxError,arg(2))
DefineString=ReplaceString(DefineString, "${Version}",PgmVersion,arg(2))
ChangeTime=date('Weekday') || ', ' || date() || ' ' ||GetAmPmTime()
DefineString=ReplaceString(DefineString, "${ChangeTime}",ChangeTime,arg(2))
DefineString=ReplaceString(DefineString, "${CurrentLine}",GetCurrentLineContents(),arg(2))
end
end
end
return(DefineString)
ReplaceString:
TheString=arg(1)
ChangeFrom=arg(2)
ChangeTo=arg(3)
ChangeCntVar=arg(4)
LimitChange=arg(5)
if LimitChange='' then
LimitChange=99999
ChangeFromLength=length(ChangeFrom)
ChangeToLength=length(ChangeTo)
FoundPosn=pos(ChangeFrom,TheString)
ReplaceStringCounter=0
do while FoundPosn<>0&LimitChange>0
TheString=left(TheString,FoundPosn-1)||ChangeTo||substr(TheString,FoundPosn+ChangeFromLength)
FoundPosn=pos(ChangeFrom,TheString,FoundPosn+ChangeToLength)
ReplaceStringCounter=ReplaceStringCounter+1
LimitChange=LimitChange-1
end
if ChangeCntVar<> '' then
call value ChangeCntVar,value(ChangeCntVar)+ReplaceStringCounter
return(TheString)
GetCurrentLineContents:
TheCurrentLine=G.StdVar.CurrentPosn
if TextFile.0=0 then
TheCurrentLine="<FileEmpty>"
else
do
if TheCurrentLine=0 then
TheCurrentLine=TextFile.1
else
TheCurrentLine=TextFile.TheCurrentLine
end
return(TheCurrentLine)
SetReturnCodeDefine:
G.StdVar.LastRc=arg(1)
SayTheRc=arg(3)
if G.StdVar.LastRc=0 then
G.StdVar.LastRcReason="OK"
else
do
G.StdVar.LastRcReason=arg(2)
if SayTheRc<> 'NOSAY' then
call SayIt 2, "WARNING: Rc=" || G.StdVar.LastRc || ', ' ||G.StdVar.LastRcReason
end
return
SetCommandSyntaxReturnCodeDefine:
TheRc=arg(1)
TheReason='Syntax Error : ' ||arg(2)
call SetReturnCodeDefine TheRc,TheReason, 'NOSAY'
call SayIt 1,TheReason
G.StdVar.SyntaxError=G.StdVar.SyntaxError+1
return
SetReplaceCountDefine:
G.StdVar.ReplaceCount=arg(1)
return
EndDefine:
/*
*$Header:E:/DB/PVCS.IT/OS2/TEXTEDIT/PROCESSF.XHV 1.4 17 Apr 1999 08:54:08 Dennis_Bareis $
*/
WantedSayLevel=9999
WantedSayLevelDebug=WantedSayLevel
DebugMode='N'
signal EndProcessF
SayIfDebugOn:
if DebugMode='Y' then
say arg(1)
return
ProcessChangeFile:
say ''
say 'PROCESSING'
say '~~~~~~~~~~'
NextChangeLine=1
LastChangeLine=ChangeFile.0
do while NextChangeLine<=LastChangeLine
ChangeLine=ChangeFile.NextChangeLine
LineBeingProcessed=ChangeLine
LineSourceBeingProcessed=ChangeFile.SourceInfo.NextChangeLine
NextChangeLine=NextChangeLine+1
if left(ChangeLine,CmtLineLng)=CmtLine then
iterate
InLineComment=lastpos(CmtInline,ChangeLine)
if InLineComment<>0 then
do
ChangeLine=strip(left(ChangeLine,InLineComment-1))
if ChangeLine='' then
iterate
end
if left(ChangeLine,1)='#' then
do
HashRc='?'
parse var ChangeLine FirstWord SecondWordEtc
FirstWord=translate(substr(FirstWord,2))
if FirstWord='IF' then
do
LineAfterChanges=ReplaceHashAndStandardDefines(ChangeLine, "ChangesMade")
if ChangesMade<>0 then
parse var LineAfterChanges FirstWord SecondWordEtc
HashRc=ProcessHashIf(SecondWordEtc)
end
else
do
if FirstWord='ELSEIF' then
HashRc=ProcessHashElse()
else
do
if FirstWord='ENDIF' then
HashRc=ProcessHashEndif()
end
end
if HashRc<> '?' then
do
if HashRc='OK' then
iterate
else
do
say 'ERROR: #if/elseif/endif failed, Reason = ' ||HashRc
return(109)
end
end
end
if WantLine()='Y' then
do
ProcessLineRc=ProcessChangeLine(ChangeLine, 'NextChangeLine')
if ProcessLineRc<>0 then
do
If ProcessLineRc='OK' then
return(0)
else
return(ProcessLineRc)
end
end
end
return(0)
ProcessChangeLine:
TheLine=arg(1)
NameOfLineVar=arg(2)
if DebugMode='Y' then
do
ThisLineNumb=value(NameOfLineVar)
if length(ThisLineNumb)>=4 then
LineNumberStr=ThisLineNumb
else
LineNumberStr=right(' ' ||ThisLineNumb,4)
end
if left(TheLine,1)='#' then
do
if DebugMode='Y' then
say LineNumberStr|| ' : COMMAND: ' ||TheLine
parse var TheLine HashCmd ItsParameters
HashCmd=translate(HashCmd)
select
when HashCmd="#DEFINE" | HashCmd = "#DEFINE+" then
do
if HashCmd="#DEFINE+" then
ItsParameters=ReplaceHashAndStandardDefines(ItsParameters)
parse var ItsParameters HashDefineV Rest
HashDefineC=GetQuotedText(Rest, "Rest")
if HashDefineC<> 'ERROR' then
do
if Rest<> '' then
do
call SetCommandSyntaxReturnCodeDefine 185, 'Extra unexpected parameters of "' || Rest || '" found on #define'
return(186)
end
return(AddHashDefine(HashDefineV,strip(HashDefineC)))
end
end
when HashCmd="#COMMENT" then
do
ItsParameters=ReplaceHashAndStandardDefines(ItsParameters)
_CmtLine=GetQuotedText(ItsParameters, "Rest")
if _CmtLine='ERROR' then
return(203)
_CmtInline=GetQuotedText(Rest, "Rest")
if _CmtInline='ERROR' then
return(206)
if Rest<> '' then
do
call SetCommandSyntaxReturnCodeDefine 211, 'Extra unexpected parameters of "' || Rest || '" found on #define'
return(212)
end
CmtLine=_CmtLine
CmtInline=_CmtInline
CmtLineLng=length(CmtLine)
return(0)
end
otherwise
do
call SetCommandSyntaxReturnCodeDefine 225, 'Unknown #command of "' || TheLine || '" specified.'
return(226)
end
end
end
else
do
if left(TheLine,1)<> '@' then
DisplayThisLine='Y'
else
do
TheLine=substr(TheLine,2)
DisplayThisLine='N'
end
if DebugMode='Y' then
say LineNumberStr|| ' : COMMAND BEFORE: ' ||TheLine
TheLineVarsReplaced=ReplaceHashAndStandardDefines(TheLine)
if DebugMode='Y' then
do
if TheLineVarsReplaced<>TheLine then
say LineNumberStr|| ' : COMMAND AFTER : ' ||TheLineVarsReplaced
end
else
do
if DisplayThisLine='Y' then
say 'COMMAND: ' ||TheLineVarsReplaced
end
parse var TheLineVarsReplaced Command ItsParameters
Command=translate(Command)
ItsParameters=strip(ItsParameters)
select
when Command="DEBUG" then
do
DebugRc=ProcessDebug(ItsParameters)
end
when Command="SAYLEVEL" then
do
WantedSayLevelDebug=GetPositiveInteger(ItsParameters)
if WantedSayLevelDebug='ERROR' then
WantedSayLevelDebug=9999
if DebugMode='N' then
WantedSayLevel=WantedSayLevelDebug
end
when Command="SAY" then
do
if ItsParameters='' then
SayWhat=''
else
SayWhat=GetQuotedText(ItsParameters)
if SayWhat<> 'ERROR' then
call SayIt 0,SayWhat, ''
end
when Command="SETPATH" then
do
TheRc=HandlePathCommand(Command,ItsParameters)
end
when Command="LIBPATH" then
do
TheRc=HandlePathCommand(Command,ItsParameters)
end
when Command="TOP" then
do
G.StdVar.CurrentPosn=0
call SetReturnCodeDefine 0
call SayIt 3, 'Now at Location = ' ||G.StdVar.CurrentPosn
end
when Command="BOTTOM" then
do
G.StdVar.CurrentPosn=TextFile.0
call SetReturnCodeDefine 0
call SayIt 3, 'Now at Location = ' ||G.StdVar.CurrentPosn
end
when Command="MOVETO" then
do
MoveTo=GetPositiveInteger(ItsParameters)
if MoveTo<> 'ERROR' then
do
if MoveTo<=TextFile.0 then
do
G.StdVar.CurrentPosn=MoveTo
call SayIt 3, 'Now at Location = ' ||G.StdVar.CurrentPosn
end
else
do
G.StdVar.CurrentPosn=TextFile.0
call SetReturnCodeDefine 350, "Can not MoveTo " || MoveTo || ' there are not enough lines, moved to end (' || G.StdVar.CurrentPosn || ')'
end
end
end
when Command="DOWN" then
do
if ItsParameters="" then
MoveDown=1
else
MoveDown=GetPositiveInteger(ItsParameters)
if MoveDown<> 'ERROR' then
do
MaxMove=TextFile.0-G.StdVar.CurrentPosn
if MoveDown<=MaxMove then
call SetReturnCodeDefine 0
else
do
MoveDown=MaxMove
call SetReturnCodeDefine 377, "Can not move down " || ItsParameters || ' lines, moved to end - ' || MoveDown || ' lines'
end
G.StdVar.CurrentPosn=G.StdVar.CurrentPosn+MoveDown
call SayIt 3, 'Now at Location = ' ||G.StdVar.CurrentPosn
end
end
when Command="UP" then
do
if ItsParameters="" then
MoveUp=1
else
MoveUp=GetPositiveInteger(ItsParameters)
if MoveUp<> 'ERROR' then
do
if MoveUp<=G.StdVar.CurrentPosn then
call SetReturnCodeDefine 0
else
do
MoveUp=MaxMove
call SetReturnCodeDefine 405, "Can not move up" || ItsParameters || ' lines, moved to start - ' || MoveUp || ' lines'
end
G.StdVar.CurrentPosn=G.StdVar.CurrentPosn-MoveUp
call SayIt 3, 'Now at Location = ' ||G.StdVar.CurrentPosn
end
end
when Command="FIND" then
do
FindRc=PerformFind(ItsParameters)
end
when Command="DELETEBLOCK" then
do
DeleteRc=ProcessDeleteBlock(ItsParameters)
end
when Command="REPLACELINES" then
do
ReplaceRc=ProcessReplaceLines(ItsParameters)
end
when Command="CASESENSITIVE" then
do
ReplaceRc=ProcessCaseSensitive(ItsParameters)
end
when Command="EXIT" then
do
call SayIt 3, 'User requested exit...'
ReturnCode=GetPositiveInteger(ItsParameters, "Rest")
if ReturnCode='ERROR' then
returnCode=445
else
do
if Rest="" then
Reason=""
else
do
Reason=GetQuotedText(Rest)
if Reason='ERROR' then
Reason='Exiting, reason is unknown due to syntax error!'
end
if Reason<> '' then
call SayIt 0,Reason
end
if ReturnCode=0 then
ReturnCode='OK'
return(ReturnCode)
end
when Command="DELETELINES" then
do
if ItsParameters="" then
DeleteCount=1
else
DeleteCount=GetInteger(ItsParameters)
if DeleteCount<> 'ERROR' then
do
OriginalCurrent=G.StdVar.CurrentPosn
DeleteFrom=G.StdVar.CurrentPosn
if DeleteFrom=0 then
DeleteFrom=1
if TextFile.0=0 then
call SetCommandSyntaxReturnCodeDefine 487, 'Can not delete any lines (file is completely empty!)'
else
do
CantDelete=""
if DeleteCount<0 then
do
DeleteCount=abs(DeleteCount)
DeleteEndIndex=DeleteFrom
DeleteStartIndex=(DeleteEndIndex-DeleteCount)+1
if DeleteStartIndex<1 then
do
call SetReturnCodeDefine 501, "Can not delete " || abs(DeleteCount) || ' lines (backwards), deleting to top'
DeleteStartIndex=1
end
NewCurrent=DeleteFrom-DeleteCount
if NewCurrent<0 then
NewCurrent=0
end
else
do
DeleteStartIndex=DeleteFrom
DeleteEndIndex=(DeleteStartIndex+DeleteCount)-1
if DeleteEndIndex>TextFile.0 then
do
call SetReturnCodeDefine 516, "Can not delete " || DeleteCount || ' lines (forwards), deleting to end'
DeleteEndIndex=TextFile.0
end
NewCurrent=OriginalCurrent
end
if DeleteEndIndex>TextFile.0 then
call SetReturnCodeDefine 524, "Can not delete lines"
else
do
call DeleteLinesByIndexes DeleteStartIndex,DeleteEndIndex
if NewCurrent>TextFile.0 then
NewCurrent=TextFile.0
G.StdVar.CurrentPosn=NewCurrent
call SetReturnCodeDefine 0
end
end
end
end
when Command="EVALUATE" then
do
ProcessRc=ProcessEvaluate(ItsParameters)
end
when Command="EXECUTE" then
do
CmdToEval=GetQuotedText(ItsParameters)
if CmdToEval<> 'ERROR' then
do
call SetReturnCodeDefine 0
Rc=0
interpret "call AddressCmd '@" || CmdToEval || "'"
call SetReturnCodeDefine Rc, "Rc from EXECUTE"
end
end
when Command="WILDCARD" then
do
WildChar=GetQuotedText(ItsParameters)
if WildChar<> 'ERROR' then
do
if length(WildChar)<>1 then
call SetCommandSyntaxReturnCodeDefine 568, 'Invalid Wildchar of of "' || WildChar || '" specified (should be 1 byte long!).'
else
do
call SetReturnCodeDefine 0
WildCardChar=WildChar
end
end
end
when Command="INSERTLINE" then
do
NewLine=GetQuotedText(ItsParameters)
if NewLine<> 'ERROR' then
do
call MakeSpaceForLine G.StdVar.CurrentPosn
NewLineIndex=G.StdVar.CurrentPosn+1
TextFile.NewLineIndex=NewLine
call SayIt 3, 'New line is being inserted as line #' ||NewLineIndex
G.StdVar.CurrentPosn=G.StdVar.CurrentPosn+1
call SetReturnCodeDefine 0
end
end
when Command="REPLACETEXT" then
do
call SetReplaceCountDefine 0
MaxReplace=GetInteger(ItsParameters, "Rest")
if MaxReplace<> 'ERROR' then
do
BeforeString=GetQuotedText(Rest, "Rest")
if BeforeString<> 'ERROR' then
do
AfterString=GetQuotedText(Rest)
if AfterString<> 'ERROR' then
do
if MaxReplace<0 then
do
StepDirection=-1
MaxReplace=abs(MaxReplace)
StartAt=G.StdVar.CurrentPosn
StopAt=0
end
else
do
StepDirection=1
StartAt=G.StdVar.CurrentPosn+1
StopAt=TextFile.0+1
end
if StartAt=StopAt then
call SetReturnCodeDefine 635, "Can not perform REPLACETEXT command - No available lines to process"
else
do
LineIndex=StartAt
TotalChanges=0
do while LineIndex<>StopAt
OneLine=TextFile.LineIndex
Changes=0
OneLine=ReplaceString(OneLine,BeforeString,AfterString, "Changes",MaxReplace)
if Changes<>0 then
call SayIt 3,Changes|| ' changes made on line #' ||LineIndex
TextFile.LineIndex=OneLine
TotalChanges=TotalChanges+Changes
MaxReplace=MaxReplace-Changes
if MaxReplace<=0 then
leave
LineIndex=LineIndex+StepDirection
end
call SetReplaceCountDefine TotalChanges
call SetReturnCodeDefine 0
end
end
end
end
end
when Command="CHECKPOINT" then
do
CheckpointFile=G.StdVar.TextFileOut
if ItsParameters<> '' then
CheckpointFile=GetQuotedText(ItsParameters)
if CheckpointFile='ERROR' then
call SetCommandSyntaxReturnCodeDefine 681, 'Invalid CHECKPOINT filename of "' || ItsParameters || '" specified.'
else
do
call SayIt 3, 'Checkpointing to "' || CheckpointFile || '"'
call _SysFileDelete CheckpointFile
NumberFailingLines=0
do LineIndex=1 to TextFile.0
NumberFailingLines=NumberFailingLines+lineout(CheckpointFile,TextFile.LineIndex)
end
FileError=IoError(CheckpointFile)
if FileError='NO' then
call SetReturnCodeDefine 0
else
call SetReturnCodeDefine 700, 'Checkpoint I/O error - ' ||FileError
CloseRc=stream(CheckpointFile, 'c', 'close')
end
end
otherwise
do
call SetCommandSyntaxReturnCodeDefine 711, 'Unknown command of "' || TheLineVarsReplaced || '" specified.'
end
end
end
return(0)
SayIt:
SayLevel=arg(1)
SayItText=arg(2)
if arg(3, 'Exists')=1 then
SayItChar=arg(3)
else
SayItChar='>'
if WantedSayLevel<SayLevel then
return('N')
else
do
if arg(1)="" then
say ''
else
say ' ' ||SayItChar||SayItText
return('Y')
end
GetQuotedText:
TheString=strip(arg(1))
RestVarName=arg(2)
if TheString='' then
do
call SetCommandSyntaxReturnCodeDefine 762, 'Expect a quoted string, no parameters available'
return('ERROR')
end
QuoteChar=left(TheString,1)
if datatype(QuoteChar, 'Alphanumeric')then
do
call SetCommandSyntaxReturnCodeDefine 770, 'Found an invalid quote character of "' || QuoteChar || '"'
return('ERROR')
end
SecondQuotePosn=pos(QuoteChar,substr(TheString,2))
if SecondQuotePosn<>0 then
SecondQuotePosn=SecondQuotePosn+1
else
do
call SetCommandSyntaxReturnCodeDefine 780, 'Could not find a matching end quote character of "' || QuoteChar || '"'
return('ERROR')
end
QuotedString=substr(TheString,2,SecondQuotePosn-2)
TheRest=substr(TheString,SecondQuotePosn+1)
if TheRest<> '' then
do
if left(TheRest,1)<> ' ' then
do
call SetCommandSyntaxReturnCodeDefine 792, 'There is no whitespace after the 2nd quote char of "' || QuoteChar || '" (did not expect to find "' || left(TheRest, 1) || '")'
return('ERROR')
end
end
TheRest=strip(TheRest)
if RestVarName<> '' then
call value RestVarName,TheRest
else
do
if TheRest<> '' then
do
call SetCommandSyntaxReturnCodeDefine 808, 'Extra unexpected parameters of "' || TheRest || '" found'
return('ERROR')
end
end
return(QuotedString)
GetInteger:
TheString=arg(1)
RestVarName=arg(2)
parse var TheString FirstWord TheRest
if FirstWord='' then
do
call SetCommandSyntaxReturnCodeDefine 828, 'Expect a number, no parameters available'
return('ERROR')
end
if translate(FirstWord)='ALL' | translate(FirstWord) = '+ALL' then
FirstWord=99999
if translate(FirstWord)='-ALL' then
FirstWord=-99999
if\datatype(FirstWord, 'Whole number')then
do
call SetCommandSyntaxReturnCodeDefine 837, 'Found a non-numeric parameter of ' ||FirstWord
return('ERROR')
end
if RestVarName<> '' then
call value RestVarName,TheRest
else
do
if TheRest<> '' then
do
call SetCommandSyntaxReturnCodeDefine 849, 'Extra unexpected parameters of "' || TheRest || '" found'
return('ERROR')
end
end
return(FirstWord)
GetPositiveInteger:
PositiveInteger=GetInteger(arg(1),arg(2))
if PositiveInteger='ERROR' then
return('ERROR')
if PositiveInteger<0 then
do
call SetCommandSyntaxReturnCodeDefine 869, 'Expected a positive integer, found negative one!'
return('ERROR')
end
return(PositiveInteger)
MakeSpaceForLine:
LastOne=arg(1)+1
StartAt=TextFile.0
do LineIndex=StartAt to LastOne by-1
UpOne=LineIndex+1
TextFile.UpOne=TextFile.LineIndex
end
TextFile.LastOne='*FreeSpace*'
TextFile.0=TextFile.0+1
return
DeleteLinesByIndexes:
HoleStart=arg(1)
HoleEnd=arg(2)
call SayIt 3, 'Deleting lines ' || HoleStart || ' to ' ||HoleEnd
do SayIndex=HoleStart to HoleEnd
call SayIt 50, ' Line #' || SayIndex ': "' || TextFile.SayIndex || '"'
end
if HoleEnd=TextFile.0 then
do
TextFile.0=HoleStart-1
end
else
do
MoveAmount=(HoleEnd-HoleStart)+1
do MoveFromIndex=HoleEnd+1 to TextFile.0
MoveToIndex=MoveFromIndex-MoveAmount
TextFile.MoveToIndex=TextFile.MoveFromIndex
end
TextFile.0=TextFile.0-MoveAmount
end
if G.StdVar.CurrentPosn>TextFile.0 then
G.StdVar.CurrentPosn=TextFile.0
return
ProcessDeleteBlock:
FromWildCard=GetQuotedText(arg(1), 'Rest')
if FromWildCard='ERROR' then
return(947)
if Rest='' then
ToWildCard=FromWildCard
else
do
ToWildCard=GetQuotedText(Rest)
if ToWildCard='ERROR' then
return(957)
end
StartPosn=SearchForwardsForWildcard(G.StdVar.CurrentPosn,FromWildCard)
if StartPosn=0 then
do
call SetReturnCodeDefine 964, 'Could not find a line matching the starting specification (StartingPosn=' || G.StdVar.CurrentPosn || ')!'
return(965)
end
EndPosn=SearchForwardsForWildcard(StartPosn,ToWildCard)
if EndPosn=0 then
do
call SetReturnCodeDefine 972, 'Could not find a line matching the ending specification!'
return(973)
end
if G.StdVar.CurrentPosn<=StartPosn then
NewPosn=G.StdVar.CurrentPosn
else
do
if G.StdVar.CurrentPosn>EndPosn then
NewPosn=G.StdVar.CurrentPosn-((EndPosn-StartPosn)+1)
else
NewPosn=StartPosn
end
call DeleteLinesByIndexes StartPosn,EndPosn
G.StdVar.CurrentPosn=NewPosn
call SetReturnCodeDefine 0
return(0)
SearchForwardsForWildcard:
StartIndex=arg(1)
if StartIndex=0 then
StartIndex=1
if StartIndex>TextFile.0 then
return(0)
do Index=StartIndex to TextFile.0
if StringsMatch(TextFile.Index,arg(2))='Y' then
return(Index)
end
return(0)
PerformFind:
FindCount=GetInteger(arg(1), "Rest")
if FindCount='ERROR' then
return(1046)
SearchFor=GetQuotedText(Rest)
if SearchFor='ERROR' then
return(1051)
if FindCount<0 then
do
FindCount=abs(FindCount)
StartAt=G.StdVar.CurrentPosn
LastOne=1
Step=-1
if StartAt=0 then
do
call SetReturnCodeDefine 1063, 'We are at top so we can not search backwards!'
return(1064)
end
end
else
do
StartAt=G.StdVar.CurrentPosn
LastOne=TextFile.0
Step=1
if StartAt=0 then
StartAt=1
end
FoundMatches=0
do Index=StartAt to LastOne by Step
if StringsMatch(TextFile.Index,SearchFor)='Y' then
do
FoundMatches=FoundMatches+1
call SayIt 3, 'Found match #' || FoundMatches || ' at Location = ' ||Index
if FoundMatches=FindCount then
do
G.StdVar.CurrentPosn=Index
call SetReturnCodeDefine 0
return(0)
end
end
end
call SetReturnCodeDefine 1097, 'We did not find what you wanted - found ' || FoundMatches || ' out of ' ||FindCount
return(1098)
ProcessReplaceLines:
call SetReplaceCountDefine 0
MaxReplaceCount=GetInteger(arg(1), "Rest")
if MaxReplaceCount='ERROR' then
return(1111)
SearchFor=GetQuotedText(Rest, "Rest")
if SearchFor='ERROR' then
return(1116)
ReplaceWith=GetQuotedText(Rest)
if ReplaceWith='ERROR' then
return(1121)
StartAt=G.StdVar.CurrentPosn
if MaxReplaceCount<0 then
do
MaxReplaceCount=abs(MaxReplaceCount)
LastOne=1
Step=-1
if StartAt=0 then
do
call SetReturnCodeDefine 1133, 'We are at top so we can not replace backwards!'
return(1134)
end
end
else
do
LastOne=TextFile.0
Step=1
if StartAt=0 then
StartAt=1
end
FoundMatches=0
do Index=StartAt to LastOne by Step
if StringsMatch(TextFile.Index,SearchFor)='Y' then
do
ReplacementLine=ReplaceString(ReplaceWith, "${ReplacedLine}",TextFile.Index)
TextFile.Index=ReplacementLine
FoundMatches=FoundMatches+1
call SetReplaceCountDefine FoundMatches
call SayIt 3, 'Found match #' || FoundMatches || ' at Location = ' ||Index
if FoundMatches=MaxReplaceCount then
do
call SetReturnCodeDefine 0
return(0)
end
end
end
call SetReturnCodeDefine 1174, 'We did not replace as many lines as you requested - replaced ' || FoundMatches || ' out of ' ||MaxReplaceCount
return(1175)
ProcessDebug:
NewMode=translate(strip(arg(1)))
select
when NewMode="OFF" then
do
if DebugMode='N' then
do
call SetReturnCodeDefine 1194, 'Tried to turn debugg off - it is already off'
return(1195)
end
WantedSayLevel=WantedSayLevelDebug
end
when NewMode="DUMPVAR" then
do
call Sayit 0, 'USER VARIABLES', '■'
call Sayit 0, '~~~~~~~~~~~~~~~~~', '■'
do DefineIndex=1 to HashDefineCount
TheVar=DefineVariable.DefineIndex
ItsContents=DefineContents.DefineIndex
if length(DefineIndex)>=3 then
LineNumberStr=DefineIndex
else
LineNumberStr=right(' ' ||DefineIndex,3)
if length(TheVar)>=32 then
PaddedVar=TheVar
else
PaddedVar=right(' ' ||TheVar,32)
call Sayit 0,LineNumberStr|| ' : ' || PaddedVar || ' = ' || ItsContents, '■'
end
say ''
end
when NewMode="LISTPGM" then
do
call Sayit 0, 'PROGRAM BEING RUN', '*'
call Sayit 0, '~~~~~~~~~~~~~~~~~', '*'
do LineIndex=1 to ChangeFile.0
if length(LineIndex)>=4 then
LineNumberStr=LineIndex
else
LineNumberStr=right(' ' ||LineIndex,4)
LineSource=right(ChangeFile.SourceInfo.LineIndex,LongestSourceInfo)
call Sayit 0,LineSource|| ' : ' || ChangeFile.LineIndex, '*'
end
say ''
end
when NewMode="FILESTATE" then
do
call Sayit 0, 'CURRENT STATE OF TEXT FILE', '|'
call Sayit 0, '~~~~~~~~~~~~~~~~~~~~~~~~~~', '|'
do LineIndex=1 to TextFile.0
if length(LineIndex)>=4 then
LineNumberStr=LineIndex
else
LineNumberStr=right(' ' ||LineIndex,4)
call Sayit 0,LineNumberStr|| ' : ' || TextFile.LineIndex, '|'
end
call Sayit 0, '', '|'
call Sayit 0, 'OTHER INFO', '|'
call Sayit 0, '~~~~~~~~~~', '|'
call Sayit 0, 'Current Posn : ' || G.StdVar.CurrentPosn, '|'
call Sayit 0, 'Current Line : ' || GetCurrentLineContents(), '|'
call Sayit 0, '# Syntax Errors: ' || G.StdVar.SyntaxError, '|'
say ''
end
otherwise
do
DebugMode='Y'
WantedSayLevel=9999
end
end
return(0)
ProcessCaseSensitive:
NewMode=translate(strip(arg(1)))
select
when NewMode="ON" then
CaseSensitive='Y'
when NewMode="OFF" then
CaseSensitive='N'
otherwise
do
call SetCommandSyntaxReturnCodeDefine 1313, 'Invalid parameter (' || NewMode || ')'
return(1314)
end
end
return(0)
ProcessEvaluate:
HashDefineAnswerName=GetQuotedText(arg(1), "Rest")
if HashDefineAnswerName='ERROR' then
return(1327)
if Rest='' then
CmdToEvaluate=HashDefineAnswerName
else
do
CmdToEvaluate=GetQuotedText(Rest)
if CmdToEvaluate='ERROR' then
return(1337)
end
signal ON SYNTAX NAME SyntaxErrorInEvaluateCommand
signal ON NOVALUE NAME UnknownVariableInEvaluateCommand
HashDefineRc=0
if HashDefineAnswerName='' then
interpret CmdToEvaluate
else
do
interpret 'EvaluateAnswer = ' ||CmdToEvaluate
HashDefineRc=AddHashDefine(HashDefineAnswerName,EvaluateAnswer)
call SetReturnCodeDefine HashDefineRc, "Rc from EVALUATE"
end
signal on NOVALUE name RexxTrapUninitializedVariable
signal on SYNTAX name RexxTrapSyntaxError
return(HashDefineRc)
SyntaxErrorInEvaluateCommand:
FailReason=errortext(RC)
call SetCommandSyntaxReturnCodeDefine 1372, 'Evaluate at "' || LineSourceBeingProcessed || '" failed with syntax error (' || FailReason || ')'
signal on NOVALUE name RexxTrapUninitializedVariable
signal on SYNTAX name RexxTrapSyntaxError
return(1377)
UnknownVariableInEvaluateCommand:
FailReason="Variable=" || condition('D')
call SetCommandSyntaxReturnCodeDefine 1384, 'Evaluate at "' || LineSourceBeingProcessed || '" failed with unknown variable (' || FailReason || ')'
signal on NOVALUE name RexxTrapUninitializedVariable
signal on SYNTAX name RexxTrapSyntaxError
return(1389)
EndProcessF:
/*
*$Header:E:/DB/PVCS.IT/OS2/TEXTEDIT/PATH.XHV 1.2 09 Mar 1999 17:38:12 Dennis_Bareis $
*/
signal EndPath
SearchForPathLine:
BeginsPathLine=arg(1)
PathVariable=arg(2)
BeginsPathLineLength=length(BeginsPathLine)
do LookIndex=1 to TextFile.0
LookLine=translate(strip(TextFile.LookIndex))
if BeginsPathLineLength<>0 then
do
if left(LookLine,BeginsPathLineLength)\==BeginsPathLine then
iterate
end
if pos(PathVariable,LookLine)<>0 then
return(LookIndex)
end
return(0)
LoadPathsIntoStem:
StemVarName=arg(1)
TheList=translate(arg(2))
Delimiter=';'
ComponentCount=0
do forever
DelimiterPos=pos(Delimiter,TheList)
if DelimiterPos=0 then
do
if TheList<> '' then
do
ComponentCount=ComponentCount+1
call value StemVarName|| '.' ||ComponentCount,strip(TheList)
end
leave
end
ThisComponent=left(TheList,DelimiterPos-1)
TheList=substr(TheList,DelimiterPos+1)
if ThisComponent<> '' then
do
ComponentCount=ComponentCount+1
call value StemVarName|| '.' ||ComponentCount,strip(ThisComponent)
end
end
call value StemVarName|| '.0',ComponentCount
return(ComponentCount)
FindPath:
do FindIndex=1 to Path.0
if Path.FindIndex=arg(1)then
return(FindIndex)
end
return(0)
DeletePath:
DeleteIndex=FindPath(arg(1))
if DeleteIndex<>0 then
do
do MoveFrom=DeleteIndex+1 to Path.0
MoveTo=MoveFrom-1
Path.MoveTo=Path.MoveFrom
end
Path.0=Path.0-1
end
return
HandlePathCommand:
PathCmd=arg(1)
PathCmdParms=translate(arg(2))
Rest=PathCmdParms
if PathCmd="SETPATH" then
do
Variable=GetQuotedText(Rest, "Rest")
if Variable='ERROR' then
return(146)
end
else
do
Variable='LIBPATH'
end
parse var Rest PathSubCmd Rest
if PathSubCmd<> 'ADDBEFORE' & PathSubCmd <> 'ADDAFTER' then
PositionPath=''
else
do
PositionPath=GetQuotedText(Rest, "Rest")
if PositionPath='ERROR' then
return(163)
end
OneOrMorePaths=GetQuotedText(Rest)
if OneOrMorePaths='ERROR' then
return(169)
if PathCmd="SETPATH" then
LineIndex=SearchForPathLine("SET ", " " || Variable || "=")
else
LineIndex=SearchForPathLine("", Variable || "=")
if LineIndex=0 then
do
call SetReturnCodeDefine 180, 'Can not find the ' || Variable || ' variable'
return(181)
end
call SayIt 3, 'Variable=' || Variable || ' was found on line #' ||LineIndex
EqualSignPos=pos('=',TextFile.LineIndex)
ConstantPart=left(TextFile.LineIndex,EqualSignPos)
DataPart=substr(TextFile.LineIndex,EqualSignPos+1)
call SayIt 3, 'Path Before=<' || DataPart || '>'
Dummy=LoadPathsIntoStem("Path",translate(DataPart))
Dummy=LoadPathsIntoStem("UserPath",OneOrMorePaths)
do UserDeleteIndex=1 to UserPath.0
call DeletePath UserPath.UserDeleteIndex
end
if PathSubCmd<> 'DELETE' then
do
if PositionPath='' then
do
if PathSubCmd='ADDSTART' then
InsertAt=1
else
InsertAt=Path.0+1
end
else
do
InsertAt=FindPath(PositionPath)
if InsertAt=0 then
do
call SetReturnCodeDefine 221, 'Can not find the relative directory "' || PositionPath || '" - will add to start'
InsertAt=1
end
else
do
if PathSubCmd='ADDAFTER' then
do
InsertAt=InsertAt+1
end
end
end
do AddIndex=1 to UserPath.0
call InsertIntoPath InsertAt,UserPath.AddIndex
InsertAt=InsertAt+1
end
end
NewList=''
do AddIndex=1 to Path.0
if AddIndex=1 then
NewList=Path.1
else
NewList=NewList|| ';' ||Path.AddIndex
end
call SayIt 3, 'Path After =<' || NewList || '>'
TextFile.LineIndex=ConstantPart||NewList
return(0)
InsertIntoPath:
InsertIndex=arg(1)
InsertPath=arg(2)
if InsertIndex>Path.0 then
do
Path.0=InsertIndex
Path.InsertIndex=InsertPath
end
else
do
do Index=Path.0 to InsertIndex by-1
UpOne=Index+1
Path.UpOne=Path.Index
end
Path.InsertIndex=InsertPath
Path.0=Path.0+1
end
return
EndPath:
/*
*$Header:E:/DB/PVCS.IT/OS2/TEXTEDIT/COMPSTR.XHV 1.1 09 Mar 1999 17:38:10 Dennis_Bareis $
*/
WildCardChar='*'
CaseSensitive='N'
signal EndCompStr
StringsMatch:procedure expose WildCardChar CaseSensitive
if CaseSensitive='Y' then
do
TestString=arg(1)
WildCardString=arg(2)
end
else
do
TestString=translate(arg(1))
WildCardString=translate(arg(2))
end
WildCardStringLng=length(WildCardString)
FirstWildPos=pos(WildCardChar,WildCardString)
if FirstWildPos=0 then
do
if TestString=WildCardString then
return('Y')
else
return('N')
end
if FirstWildPos=WildCardStringLng then
do
if left(TestString,WildCardStringLng-1)=left(WildCardString,WildCardStringLng-1)then
return('Y')
else
return('N')
end
if FirstWildPos<>1 then
do
StartWild=substr(WildCardString,1,FirstWildPos-1)
EndWild=substr(WildCardString,FirstWildPos+1)
if StringsMatch(TestString,StartWild||WildCardChar)='N' then
return('N')
return(StringsMatch(TestString,WildCardChar||EndWild))
end
SecondWildPos=lastpos(WildCardChar,WildCardString)
if FirstWildPos=SecondWildPos then
do
if right(TestString,WildCardStringLng-1)=substr(WildCardString,2)then
return('Y')
else
return('N')
end
else
do
if pos(substr(WildCardString,2,WildCardStringLng-2),TestString)<>0 then
return('Y')
else
return('N')
end
EndCompStr:
say ''
say 'LOADING FILES'
say '~~~~~~~~~~~~~'
LoadRc=LoadTextFile(TextFile)
if LoadRc<>0 then
do
say "ERROR: Can't load the text file " || TextFile || ' (Rc=' || LoadRc || ')'
exit(LoadRc)
end
IncludeLevel=0
LoadRc=LoadChangeFile(ChangeFile)
if LoadRc<>0 then
do
say "ERROR: Can't load the change file " || ChangeFile || ' (Rc=' || LoadRc || ')'
exit(LoadRc)
end
ProcessRc=ProcessChangeFile()
say ''
if ProcessRc=0 then
do
if G.StdVar.SyntaxError<>0 then
ProcessRc=G.StdVar.SyntaxError
end
say 'TEXTEDIT completed with RC = ' ||ProcessRc
exit(ProcessRc)
DisplayCopyright:
if CopyRightDisplayed='N' then
do
say '[]-------------------------------------------------------------[]'
say '| TEXTEDIT.CMD Version ' || PgmVersion || ' (C)opyright Dennis Bareis 1997 |'
say '| http://www.labyrinth.net.au/~dbareis/index.htm (db0@anz.com) |'
say '[]-------------------------------------------------------------[]'
say ''
CopyRightDisplayed='Y'
end
return
RexSystemFailure:
FailedAt=SIGL
call DisplayCopyright
call RexDumpSystemInfo
say LightRed||arg(1)||Reset
exit(FailedAt)
SetColorCodes:
EscapeChar=d2c(27)
Reset=EscapeChar|| '[0m'
LightRed=EscapeChar|| '[1;31m'
Yellow=EscapeChar|| '[1;33m'
return
RemoveColorCodes:
Reset=''
LightRed=''
Yellow=''
return
GetAmPmTime:
CivilTime=time('C'); if length(CivilTime) = 6 then CivilTime=' 'CivilTime
TheTime=time();NumSeconds=':'substr(TheTime,7,2)
return(insert(NumSeconds,CivilTime,5))
UserSyntaxError:
FailedAt=SIGL
say "SYNTAX ERROR"
say "~~~~~~~~~~~~"
say ' ' ||arg(1)
say ''
say 'CORRECT SYNTAX'
say '~~~~~~~~~~~~~~'
say ' TEXTEDIT[.CMD] TextFileBeingChanged OutputFile ChangeFile [OptionalParms]'
say ''
say 'The "OptionalParms" can be accessed from the change description file...'
exit(FailedAt)
CommonTrapHandler:
FailingLine=arg(1)
TrapHeading='BUG: ' ||arg(2)
TextDescription=arg(3)
Text=arg(4)
parse source . . SourceFileName
say Yellow||copies('=+',39)||LightRed
say TrapHeading
say copies('~',length(TrapHeading))
say substr(TextDescription,1,16)|| ': ' ||Text
if LineBeingProcessed<> '' then
do
say 'Processing Line : ' ||LineBeingProcessed
say 'Line Source : ' ||LineSourceBeingProcessed
end
say 'Failing Module : ' ||SourceFileName
say 'Failing Line # : ' ||FailingLine
say 'Failing Command : ' ||strip(SourceLine(FailingLine))
say Yellow||copies('=+',39)||Reset
say ''
exit(FailingLine)
RexxTrapUninitializedVariable:
FailedAt=SIGL
call CommonTrapHandler FailedAt, 'NoValue Abort!', 'Unknown Variable', condition('D')
RexxTrapSyntaxError:
FailedAt=SIGL
call CommonTrapHandler FailedAt, 'Syntax Error!', 'Reason',errortext(Rc)