Search inside txt file.
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

Search inside txt file.

Started by zinden, 07 October, 2005, 18:57:21

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

zinden

Hello, got a request here, need a script that can search inside a txt file and show the hits on what it found in pm.

The txt file will look like this:

http://www.gamespot.com/AVP.htm      Alien Versus Predator
http://www.gamespot.com/Beatles.htm     Beatles, action
http://www.gamespot.com/victory.htm       Victory challenge



something like that it will look like inside the text file.
Then the script can handle like: !search Alien
And a pm pops up with this:


http://www.gamespot.com/AVP.htm      Alien Versus Predator

Found 1 match.



I thought there was a script for lua4 before, because i requested it before. But cant find it anywhere.
So i hope someone can make this script for me.
Xion++ - Where it all begins
http://www.zinden.net

bastya_elvtars

Got 404 errors, but if you post a textfile for real, it is easy to make. :)
Everything could have been anything else and it would have just as much meaning.

zinden

Xion++ - Where it all begins
http://www.zinden.net

zinden

Xion++ - Where it all begins
http://www.zinden.net

zinden

function Search(curUser,aFile,aString)
	local f,e = io.open(aFile,"games.txt")						 
	local message = "\r\n---===Search Results===---\r\n" 
		while 1 do 
			local line = f:read("*l") 
			if line == nil then break 
			elseif string.find(line,aString) then 
				message = message..line.."\r\n"			 
			end 
		end 
	f:close(f)
	curUser.SendData("SearchBot",message)			
	return 1
end


thats what i got so far.
can anyone help me make it complete?
Xion++ - Where it all begins
http://www.zinden.net

bastya_elvtars

for line in f:lines() do
  if string.find(line,"wanna look 4 this",1,true) then
  -- found
end
Everything could have been anything else and it would have just as much meaning.

zinden

that didnt make so much sence to me   :))
i hope someone can make it complete with a command too.
like +search ****
and pops up some search hits.
Xion++ - Where it all begins
http://www.zinden.net

SMF spam blocked by CleanTalk