Identifying a command within a line
Posted: Wed Jan 16, 2008 8:28 am
I have a tool that looks for command keyword on a line and changes it, i.e.: "Find all instances of Procedure and change it to ProcedureC".
This is the procedure I'm using for this. Can anyone tell if I'm missing any cases?
This is the procedure I'm using for this. Can anyone tell if I'm missing any cases?
Code: Select all
Procedure KeyPart(string.s,keypart.s)
If CountString(string.s,keypart.s)
ProcedureReturn 1
EndIf
EndProcedure
Procedure FindCommand(String.s,StringToFind.s)
Macro fcEndCase()
; check for comment character and endcase
:If pos And Not KeyPart(Left(String.s,pos-1),";")
:Exists=1: ProcedureReturn Exists
:EndIf
EndMacro
String.s=LCase(String.s): StringToFind.s=LCase(StringToFind.s)
pos=FindString(String.s,Chr(9)+StringToFind.s+Chr(9),1):fcEndCase(); (tab)string(tab)
pos=FindString(String.s,Chr(9)+StringToFind.s+":",1):fcEndCase(); (tab)string:
pos=FindString(String.s,Chr(9)+StringToFind.s+".",1):fcEndCase(); (tab)string.
pos=FindString(String.s,Chr(9)+StringToFind.s+";",1):fcEndCase(); (tab)string;
pos=FindString(String.s,":"+StringToFind.s+Chr(9),1):fcEndCase(); :string(tab)
pos=FindString(String.s,":"+StringToFind.s+":",1):fcEndCase(); :string:
pos=FindString(String.s,":"+StringToFind.s+".",1):fcEndCase(); :string.
pos=FindString(String.s,":"+StringToFind.s+";",1):fcEndCase(); :string;
pos=FindString(String.s," "+StringToFind.s+" ",1):fcEndCase(); (s)string(s)
pos=FindString(String.s," "+StringToFind.s+":",1):fcEndCase(); (s)string:
pos=FindString(String.s," "+StringToFind.s+".",1):fcEndCase(); (s)string.
pos=FindString(String.s," "+StringToFind.s+";",1):fcEndCase(); (s)string;
pos=FindString(String.s,":"+StringToFind.s+" ",1):fcEndCase(); :string(s)
pos=FindString(String.s,Chr(9)+StringToFind.s+" ",1):fcEndCase(); (tab)string(s)
pos=FindString(String.s," "+StringToFind.s+Chr(9),1):fcEndCase(); (s)string(tab)
pos=Left(String.s,Len(StringToFind.s)+1)=StringToFind.s+Chr(9):fcEndCase(); |string(tab)
pos=Left(String.s,Len(StringToFind.s)+1)=StringToFind.s+" ":fcEndCase(); |string(s)
pos=Left(String.s,Len(StringToFind.s)+1)=StringToFind.s+":":fcEndCase(); |string:
pos=Left(String.s,Len(StringToFind.s)+1)=StringToFind.s+".":fcEndCase(); |string.
pos=Left(String.s,Len(StringToFind.s)+1)=StringToFind.s+";":fcEndCase(); |string;
pos=Right(String.s,Len(StringToFind.s)+1)=Chr(9)+StringToFind.s:fcEndCase(); (tab)string(crlf)
pos=Right(String.s,Len(StringToFind.s)+1)=" "+StringToFind.s:fcEndCase(); (s)string(crlf)
pos=Right(String.s,Len(StringToFind.s)+1)=":"+StringToFind.s:fcEndCase(); :string(crlf)
If String.s=StringToFind.s; |string(crlf)
Exists=1
EndIf
ProcedureReturn Exists
EndProcedure