This version includes:
1) Searching in current program (or in last edited) Shift-USER S (S is button [9])
2) Searching in all programs Shift-USER Shift-S (S is button [9])
3) Searching in current note (or in last edited Note if u are not in editor)
Shift-USER Note (Note is button [0])
4) Searching in all notes
Shift-USER Shift-Note (Note is button [0])
The program now contains semi-unversal function GlobSearch with arguments: str, IType, BCaseSense
str - string to search.
IType: 1 - Local searching in program, 2- Global searching in programs, 3-Local searching in note, 4-Global searching in notes.
BCaseSense: 1 - Case insensitive, other values - Case sensitive
Currently I hardcoded case insensitive search everywhere, so one need to change searching dialog to add check box
for sensitive searching (just in case).
Text of program, but better use attached file:
Code:
ReplToUpper(Str)
BEGIN
FOR I FROM 1 TO DIM(Str) DO
IF Str(I)≥97 AND Str(I)<123 THEN
Str(I):=Str(I)-32;
END;
END;
RETURN Str;
END;
CONCATSTRS(lst)
BEGIN
LOCAL res:="";
FOR I FROM 1 TO SIZE(lst) DO
res:=res+lst(I);
END;
RETURN res;
END;
EXPORT GlobSearch(str,IType,BCaseSense)
BEGIN
IF BCaseSense==1 THEN
str:=ReplToUpper(str);
END;
LOCAL AText:="";
CASE
IF IType==1 THEN AText:=Programs(1); END; // Current program
IF IType==2 THEN // Search in all programs
LOCAL TitleList:=Programs;
AText:=CONCATSTRS(MAKELIST(CHAR(10)+TitleList(X)+CHAR(13)+Programs(X),
X,1,SIZE(TitleList)));
END;
IF IType==3 THEN // Search in current Note
AText:= Notes(1);
END;
IF IType==4 THEN // Search in all notes
LOCAL TitleList:=Notes;
AText:=CONCATSTRS(MAKELIST(CHAR(10)+TitleList(X)+CHAR(13)+Notes(X),
X,1,SIZE(TitleList)));
END;
DEFAULT
PRINT("IType argument can be 1-4");
RETURN 0;
END;
LOCAL Name:="";
LOCAL L:=DIM(AText);
LOCAL LineNo:=1;
LOCAL SLine:=1;
LOCAL i;
PRINT();
FOR i FROM 1 TO L DO
LOCAL cCH:=AText(i);
IF cCH==13 THEN
Name:=MID(AText,SLine,i-SLine+1); // Program or Note title
SLine:=i+1;
LineNo:=1;
END;
IF cCH==10 OR i==L THEN
LOCAL s:=MID(AText,SLine,i-SLine+1);
IF BCaseSense==1 THEN
s:=ReplToUpper(s);
END;
IF INSTRING(s,str) THEN
PRINT(Name+":"+LineNo+": "+s);
END;
SLine:=i+1;
LineNo:=LineNo+1;
END;
END;
PRINT("SEARCH FINISHED.");
RETURN 1;
END;
KEY KS_9() // Shift-USER Shift-S
BEGIN
LOCAL str:="";
INPUT(str,"Global search in programs","string=","Enter string:","");
IF str<>"" THEN
GlobSearch(str,2,1);
END;
RETURN "";
END;
KEY K_9() // Shift-USER S
BEGIN
LOCAL str:="";
INPUT(str,"Local search in program","string=","Enter string:","");
IF str<>"" THEN
GlobSearch(str,1,1);
END;
RETURN "";
END;
KEY K_0() // Shift-USER [Notes] (0 button)
BEGIN
LOCAL str:="";
INPUT(str,"Search in current Note","string=","Enter string:","");
IF str<>"" THEN
GlobSearch(str,3,1);
END;
RETURN "";
END;
KEY KS_0() // Shift-USER Shift-[Notes] (0 button)
BEGIN
LOCAL str:="";
INPUT(str,"Global search in Notes","string=","Enter string:","");
IF str<>"" THEN
GlobSearch(str,4,1);
END;
RETURN "";
END;
Best regards
XSet