Originally Posted By: Riamus2
You might consider using an INI file instead or else check to see if the item exists in the file before writing the update and if it exists, overwrite that line or else delete it and add the new line.


We are finding out now that you maybe right lol.Although it works for the most part,we are already starting to run into trouble.

Basically we are trying to have a txt file that has a list of Q&A's (question on one line and the answer on the second line) with a space then the next Q&A and so on.

Example of the txt file:

Code:
question1 here
answer 1 here

question2 here
answer2 here


I thought having a key word would make it easy but I found that the key word can mean more than one result and its hard to come up with common key words and we had to have the Q&A all on one line so it noticed it all to the user.

How would we go about making it so a user can come in and type !faq MY QUESTION HERE and have it search the whole entire txt (or ini as you said if thats better) and return all the answers in the file.

Code:

<user1> !faq my question here (could be up to 8 words)
*D00M* Found:- "your answer1"
*D00M* Found:- "your answer2"
*D00M* Found:- "your answer3"
<user4> !faq my question here (could be up to 4 words)
*D00M* Found:- "your answer1"
*D00M* Found:- "your answer2"


The above is basically what we are trying to do and as you said Riamus2 updating is really a fail.We can add a single line to the txt (with no real control/spaces) but to delete or replace lines I have to edit the txt itself outside of mirc. To be honest I think we are in over our heads but any tips would be great ,TIA wink

Code we have atm:
Code:
on *:TEXT:*:#MY_CHAN:{
  if ($1 == !help) .notice $nick Here is a list of triggers that are used in this channel: !clog  (latest change log) - !kw (list of key words for !faq) - !faq KEY_WORD (e.g. !faq BSG) - !version (Main thread LINK HERE). 
  elseif ($1 == !clog) .play -n $nick c:\InvisionOLD\clog.txt 1000
  elseif ($1 == !faq) .notice $nick Found:- " $+ $read(faq.txt,sn,$$2) $+ "
  elseif ($1 == !kw) .play -n $nick c:\InvisionOLD\kw.txt 1000
  elseif ($1 == !version) .notice $nick Current version: x.xx.xx http://some.website.com
}
menu * {
  .Add FAQs: var %a $?="Add FAQs Here ,e.g BSG - ANSWER HERE:" | write FAQ.txt %a
}



Last edited by D00M; 09/02/11 05:24 PM.