Help to view a 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

Help to view a file

Started by kb2000, 23 January, 2004, 19:10:14

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

kb2000

I have file in birthday.dat
when i use a command it should be displayed. In that file i have list of birthday dates

example like this

01.02.04Monday person's name is here

like this i have few lines......

How to make this type of file and display it as it is.

Now it is displaying everything next and next and etc.....

Thanks in advance...

plop

  readfrom(file)
   while 1 do
      local line = read() 
      if ( line == nil ) then 
         break 
      else 
         user:SendPM(Bot, line)
      end
   end
   readfrom()

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

kb2000

Sorry plop,

Can you change in this code
------------------------------------------------------------------------code
--//Festival Board Bot
--//(Mr420)
--//A Simple Request Board For The Hub
--//Version 3.0

botname = "FestivalBot"
bot_email = "someone@yahoo.com"
bot_speed = "Fast Enough"
bot_descr = "Type !help In PM To Me."
bot_share_size = 420.01 * 1024 *1024
my_info_string = "$MyINFO $ALL "..botname.." "..bot_descr.."$ $"..bot_speed..strchar( 1 ).."$"..bot_email
TimeSpanInMinutes = 600   --//You May Change This

function Main()
frmHub:RegBot(botname)
my_info_string = "$MyINFO $ALL "..botname.." "..bot_descr.."$ $"..bot_speed..strchar( 1 ).."$"..bot_email..
"$"..bot_share_size.."$"
SetTimer(TimeSpanInMinutes*33000)
StartTimer()
end

function NewUserConnected(curUser)
curUser:SendData( my_info_string )
end

function OpConnected(curUser)
curUser:SendData( my_info_string )
end

function OnTimer()

--//Note that a "|" denotes a break in the line

SendToAll("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
SendToAll("    HI THERE!!!!, I'm The FestivalBot.")
SendToAll("    Do You Need To know the Upcoming Festivals???")
SendToAll("    CHECK IT!!!")
SendToAll("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
SendToAll("  To Request A File, Simply Send !help As A Private Message")
SendToAll("  To FestBot.")
SendToAll("  Remember To Check The Upcoming Festivals.....")
SendToAll("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")

end

function tokenize (inString,token)
_WORDS = {}
local matcher = "([^?"..token.."]+)"
gsub(inString, matcher, function (w) tinsert(_WORDS,w) end)
return _WORDS
end

function GetArgs(data)
s,e,whoTo,from,cmd,arg,arg2 = strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)%s+(.*)")
return arg,arg2
end

function DataArrival(user, data)
if(strsub(data, 1, 4) == "$To:") then
data=strsub(data,1,strlen(data)-1)
s,e,whoTo = strfind(data,"$To:%s+(%S+)")
if (whoTo == botname) then
s,e,whoTo,from,cmd = strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)")

if (cmd=="!help") then
user:SendPM(botname,"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
user:SendPM(botname,"    This is the FestivalBot!")
user:SendPM(botname,"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
user:SendPM(botname," Type !help To View This Help Menu.")
user:SendPM(botname," Type !add To Request A File.")
user:SendPM(botname," Type !list To List The Festivals & Posted Updates.")
user:SendPM(botname,"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
user:SendPM(botname," Please Add the missed Festivals.")
user:SendPM(botname,"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
end

if (cmd=="!add") then
SendToAll("***New Festival Added***")
arg= GetArgs(data)
local handle=openfile("festivals.dat","a")
write(handle,"("..user.sName..") requested :"..arg.."?")
user:SendPM(botname,"Festival entry saved ....")
closefile(handle)
end

if (cmd=="!list") then
handle2=openfile("festivals.dat","r")
if (handle2==nil) then
else
line = read(handle2,"*a")
line=strsub(line,1,strlen(line)-1)
linearray=tokenize(line,"?")
for i=1,linearray.n do
user:SendPM(botname,linearray)
end
closefile(handle2)
end

end
end
end
end
---------
Thanks in advance...

plop

yep i could.
------------------------------------------------------------------------code
--//Festival Board Bot
--//(Mr420)
--//A Simple Request Board For The Hub
--//Version 3.0

botname = "FestivalBot"
bot_email = "someone@yahoo.com"
bot_speed = "Fast Enough"
bot_descr = "Type !help In PM To Me."
bot_share_size = 420.01 * 1024 *1024
my_info_string = "$MyINFO $ALL "..botname.." "..bot_descr.."$ $"..bot_speed..strchar( 1 ).."$"..bot_email
TimeSpanInMinutes = 600 --//You May Change This

function Main()
   frmHub:RegBot(botname)my_info_string = "$MyINFO $ALL "..botname.." "..bot_descr.."$ $"..bot_speed..strchar( 1 ).."$"..bot_email.."$"..bot_share_size.."$"
   SetTimer(TimeSpanInMinutes*33000)
   StartTimer()
end

function NewUserConnected(curUser)
   curUser:SendData( my_info_string )
end

function OpConnected(curUser)
   curUser:SendData( my_info_string )
end

function OnTimer()
   --//Note that a "|" denotes a break in the line
   SendToAll("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
   SendToAll(" HI THERE!!!!, I'm The FestivalBot.")
   SendToAll(" Do You Need To know the Upcoming Festivals???")
   SendToAll(" CHECK IT!!!")
   SendToAll("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
   SendToAll(" To Request A File, Simply Send !help As A Private Message")
   SendToAll(" To FestBot.")
   SendToAll(" Remember To Check The Upcoming Festivals.....")
   SendToAll("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
end

function tokenize (inString,token)
   _WORDS = {}
   local matcher = "([^?"..token.."]+)"
   gsub(inString, matcher, function (w) tinsert(_WORDS,w) end)
   return _WORDS
end

function GetArgs(data)
   s,e,whoTo,from,cmd,arg,arg2 = strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)%s+(.*)")
   return arg,arg2
end

function DataArrival(user, data)
   if(strsub(data, 1, 4) == "$To:") then
      data=strsub(data,1,strlen(data)-1)
      s,e,whoTo = strfind(data,"$To:%s+(%S+)")
      if (whoTo == botname) then
         s,e,whoTo,from,cmd = strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)")
         if (cmd=="!help") then
            user:SendPM(botname,"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
            user:SendPM(botname," This is the FestivalBot!")
            user:SendPM(botname,"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
            user:SendPM(botname," Type !help To View This Help Menu.")
            user:SendPM(botname," Type !add  To Request A File.")
            user:SendPM(botname," Type !list To List The Festivals & Posted Updates.")
            user:SendPM(botname," Type !birthday To List The birthday's from the hub users.")
            user:SendPM(botname,"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
            user:SendPM(botname," Please Add the missed Festivals.")
            user:SendPM(botname,"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
         elseif (cmd=="!add") then
            SendToAll("***New Festival Added***")
            arg= GetArgs(data)
            local handle=openfile("festivals.dat","a")
            write(handle,"("..user.sName..") requested :"..arg.."?")
            user:SendPM(botname,"Festival entry saved ....")
            closefile(handle)
         elseif (cmd=="!list") then
            handle2=openfile("festivals.dat","r")
            if (handle2==nil) then
               user:SendPM(botname, "Error file couln't be opend|")
            else
               line = read(handle2,"*a")
               line=strsub(line,1,strlen(line)-1)
               linearray=tokenize(line,"?")
               for i=1,linearray.n do
                  user:SendPM(botname,linearray[i])
               end
               closefile(handle2)
            end
         elseif (cmd=="!birthday") then
            readfrom("birthday.dat")
            while 1 do
               local line = read() 
               if ( line == nil ) then 
                  break 
               else 
                  user:SendPM(botname, line)
               end
            end
            readfrom()
         end
      end
   end
end

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

kb2000

#4
Thanks plop.... and one more request

that is to delete festivals by command

i tried adding a  "delete" cmd in the script,  but not working.... and i don't know much abt lua script, just tried but the script showed you(i mean me not "plop" or anyone) are not the one to do it.

There are professionals (like plop and others) around the forum....


So i'm asking again.. thanks for the help

Please don't misunderstand.........

pHaTTy

QuoteOriginally posted by kb2000
Thanks plop.... and one more request

that is to delete festivals by command

i tried with "delete" cmd but not working.... and i don't know lua script, just tried but the script showed you are not the one to do it.

There are professionals around the forum....


So i'm asking again.. thanks for the help

whats that suppose to mean, plop is a pro, hes probby one of the best on the forum


and btw he has not added a delete command
Resistance is futile!

kb2000

QuoteOriginally posted by (uk-kingdom)pH?tt?
QuoteOriginally posted by kb2000
Thanks plop.... and one more request

that is to delete festivals by command

i tried with "delete" cmd but not working.... and i don't know lua script, just tried but the script showed you are not the one to do it.

There are professionals around the forum....


So i'm asking again.. thanks for the help

whats that suppose to mean, plop is a pro, hes probby one of the best on the forum


and btw he has not added a delete command

hi ph?tt?,

Please read it again, that is what i mean......

pHaTTy

ok i re-read since u changed it and makes more sense to me now ty :))
Resistance is futile!

kb2000

QuoteOriginally posted by (uk-kingdom)pH?tt?
ok i re-read since u changed it and makes more sense to me now ty :))

Thanks for understanding me....... May be i think that's good you told or else everyone will think like you..... And it would be very worse for me.....

Anyway thanks again...

pHaTTy

QuoteOriginally posted by kb2000
QuoteOriginally posted by (uk-kingdom)pH?tt?
ok i re-read since u changed it and makes more sense to me now ty :))

Thanks for understanding me....... May be i think that's good you told or else everyone will think like you..... And it would be very worse for me.....

Anyway thanks again...

LoL np i usual speak my mind :)) yw
Resistance is futile!

kb2000

#10
plop, here is the code now, that i'm using and want to add the delete part also

code
--------------------------------------------------------------------
--//Festival Board Bot
--//(Mr420)
--//A Simple Request Board For The Hub
--//Version 3.0

botname = "FestivalBot"
bot_email = "someone@yahoo.com"
bot_speed = "Fast Enough"
bot_descr = "Type !help In PM To Me."
bot_share_size = 420.01 * 1024 *1024
my_info_string = "$MyINFO $ALL "..botname.." "..bot_descr.."$ $"..bot_speed..strchar( 1 ).."$"..bot_email
TimeSpanInMinutes = 600 --//You May Change This

function Main()
   frmHub:RegBot(botname)my_info_string = "$MyINFO $ALL "..botname.." "..bot_descr.."$ $"..bot_speed..strchar( 1 ).."$"..bot_email.."$"..bot_share_size.."$"
   SetTimer(TimeSpanInMinutes*33000)
   StartTimer()
end

function NewUserConnected(curUser)
   curUser:SendData( my_info_string )
end

function OpConnected(curUser)
   curUser:SendData( my_info_string )
end

function OnTimer()
   --//Note that a "|" denotes a break in the line
   SendToAll("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
   SendToAll(" HI THERE!!!!, I'm The FestivalBot.")
   SendToAll(" Do You Need To know the Upcoming Festivals???")
   SendToAll(" CHECK IT!!!")
   SendToAll("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
   SendToAll(" To Request A File, Simply Send !help As A Private Message")
   SendToAll(" To FestBot.")
   SendToAll(" Remember To Check The Upcoming Festivals.....")
   SendToAll("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
end

function tokenize (inString,token)
   _WORDS = {}
   local matcher = "([^?"..token.."]+)"
   gsub(inString, matcher, function (w) tinsert(_WORDS,w) end)
   return _WORDS
end

function GetArgs(data)
   s,e,whoTo,from,cmd,arg,arg2 = strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)%s+(.*)")
   return arg,arg2
end

function DataArrival(user, data)
   if(strsub(data, 1, 4) == "$To:") then
      data=strsub(data,1,strlen(data)-1)
      s,e,whoTo = strfind(data,"$To:%s+(%S+)")
      if (whoTo == botname) then
         s,e,whoTo,from,cmd = strfind(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S+)")
         if (cmd=="!help") then
            user:SendPM(botname,"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
            user:SendPM(botname," This is the FestivalBot!")
            user:SendPM(botname,"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
            user:SendPM(botname," Type !help To View This Help Menu.")
            user:SendPM(botname," Type !add To Request A File.")
            user:SendPM(botname," Type !festivals To List The Festivals & Posted Updates.")
            user:SendPM(botname,"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
            user:SendPM(botname," Please Add the missed Festivals.")
            user:SendPM(botname,"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
         elseif (cmd=="!add") then
            SendToAll("***New Festival Added***")
            arg= GetArgs(data)
            local handle=openfile("festivals.dat","a")
            write(handle,"("..user.sName..") added :"..arg.."?")
            user:SendPM(botname,"Festival entry saved ....")
            closefile(handle)

         elseif (cmd=="!festivals") then
            readfrom("festivals.dat")
            while 1 do
               local line = read()
               if ( line == nil ) then
                  break
               else
                  user:SendPM(botname, line)
               end
            end
            readfrom()
      end
         end
   end
end
---------------------------------------------------

Thanks again.....

pHaTTy

what do you want it to do?? delete the file? or delete the last line or delete what exactly?
Resistance is futile!

kb2000

Delete the unwanted line with the given date or festival name.....

plop

QuoteOriginally posted by kb2000
Delete the unwanted line with the given date or festival name.....
do you mind if i mod freshstuf a bit so it suits your needs for doing the same as this bot ???
i like the easy way of deleting i added to the latest version of that.
then it's also easy 2 add adding/removing of birthday's 2 it.

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

kb2000

you are welcome to mod it. What i want is to have a help command that tells the commands available and then add, read and del from file (something.dat)

TIA plop

kb2000

Hi plop,

Have you forgot my request??

plop

QuoteOriginally posted by kb2000
Hi plop,

Have you forgot my request??
no but i have more scripts on the waiting list so you gotta wait your turn. lol
if i don't post it in 3 day's i might have forgotten it.

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

pHaTTy

it might be possible, but it wil be pretty big, its going to have to do searches, save all file into memory, and remove the line, maybe table would be faster, if i get 2, ill be stright on it
Resistance is futile!

plop

QuoteOriginally posted by (uk-kingdom)pH?tt?
it might be possible, but it wil be pretty big, its going to have to do searches, save all file into memory, and remove the line, maybe table would be faster, if i get 2, ill be stright on it
thats why i suggested using freshstuff 3.3 as a base, then deleting doesn't need any searching.
you can delete by id number.
if you wanne try it be my guest.

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

kb2000

Thanks for working on...... i will wait, as i have no knowledge with scripting.....

SMF spam blocked by CleanTalk