Function LoadTextAndSearch(SearchFor:String, FileURL:String)
SearchWantedTextInFile(SearchFor, LoadText(FileURL))
End Function
Function SearchWantedTextInFile(WantedText:String,FileText:String)
WantedText = Lower(WantedText)
Local LinesSplit:String[] = FileText.split("~n")
Local Cntr
For Local AL:String = EachIn LinesSplit
Cntr = Cntr + 1
Local LENT = Len(WantedText)
For Local I = 1 To Len (AL) - LENT
If WantedText = Lower(Mid(AL, I, LENT)) Then Print
"WantedText Found At Line: " + Cntr
Next
Next
End Function
10 minutes later... lol
Here is a recursive version of same thing..
This will Also Search Folders And Sub Folders
MyTextSreacher_Req("IgnoreLackOfExtention", "TestFolder")
Function MyTextSreacher_Req(SearchFor:String, FolderOrFilePath:String)
Select FileType (FolderOrFilePath)
'Folder
Case 2
Local DirList:String[] = LoadDir(FolderOrFilePath)
For Local D:String = EachIn DirList
MyTextSreacher_Req(SearchFor, FolderOrFilePath + "/" + D)
Next
'File
Default
SearchWantedTextInFile(SearchFor, FolderOrFilePath)
End Select
End Function
Function SearchWantedTextInFile(WantedText:String, FileURL:String)
Local FileText:String = LoadText(FileURL)
WantedText = Lower(WantedText)
Local LinesSplit:String[] = FileText.split("~n")
Local Cntr
For Local AL:String = EachIn LinesSplit
Cntr = Cntr + 1
Local LENT = Len(WantedText)
For Local I = 1 To Len (AL) - LENT
If WantedText = Lower(Mid(AL, I, LENT)) Then Print "WantedText Found At File: " + FileURL + " At Line: " + Cntr
Next
Next
End Function
That's a nifty use of
String.split("~n")
To break up the text into smaller pieces to work through.
I am curious if it is better to use String.Contains(WantedText) or Instr(String,Wantedtext,Cntr) for example when actual checking within those lines?
Maybe these commands do the samee iteration "under the hood)?
Honestly I wasnt even Aware of String.Contains..
But I think its case Sensitive, and I dont want that.
Sometimes (or many times) I code things that already exists.
And later I realize that.
You cant know everything
I was wanting some PDF functions in Max-NG... Couldnt find any in the places I would suspect it should be in modules.
So I posted of any good libraries for it I could use instead, Derron pointed me to a few.
Further down the line, and though and behold, there was actually a mod for it, tucked out of the way, so I posted, and even Derron, who is pretty much "The BlitzMax-NG Guy" didnt actually know that either!
Just goes to show!
Dabz
Debzy, I always said youre a genius..
but nobody would listen
Anar... Nobody does... They have me down as a gobshite as well (They'll not be wrong though on that front, cos I know I can talk a load of cack when I have the chance :P)
;)
Dabz
Quote from: Dabzy on Jul 12, 2025, 03:48 AMI was wanting some PDF functions in Max-NG... Couldnt find any in the places I would suspect it should be in modules.
So I posted of any good libraries for it I could use instead, Derron pointed me to a few.
Further down the line, and though and behold, there was actually a mod for it, tucked out of the way, so I posted, and even Derron, who is pretty much "The BlitzMax-NG Guy" didnt actually know that either!
Just goes to show!
Dabz
I could write you some ;) 8)
Oh, this was a good few full moons back, the ones in the module worked perfectly fine me auld fruit! ;)
But just goes to show... Hidden in plain sight! :)
Dabz