Guest
May 20, 2012, 3:32 pm UTCHome arrow Commands arrow Then Do Something arrow Logfile Related Functions
header image
Logfile Related Functions
Written by Dream Dancer   
Nov 26, 2007 at 10:14 PM

Logs, while not as powerful as database's, are a pretty fair substitute for them, especially when you don't need to have a complex system in place for managing things. Do bear in mind that even though logs act random, they are read sequentially until the correct data is found, and new records are appended to the end of the log so it's not in order.

$LOG: Append record {#0} with entry {#1} to file {#2}
0 Record Name
1 Data To Enter
2 FileName
Oddball Logfile function, this creates an "Append" log where each entry is added to the end of the file in the format "Record Name","Entry Data". This was created specifically because:
  1. It's possible to overload the $LOG system to where records were being written to the wrong file.
  2. It's also possible that you really don't need the structure of a normal $LOG system but want some form of record keeping from the bot.
At this time, the $LOG is prefaced with the word "AppendLog", attempting to access an AppendLog with the normal $LOG access functions will cause it to fail without an error message, will look into making this work later. Also, currently, because of this lack of an error from the $LOG loader, it's possible to completely destroy the contents of an AppendLog with a normal $LOG action. Will put in coding to prevent this from happening later on.
$LOG: Register (add) record {#0} to file {#1}
0 Record Name
1 FileName
Adds a Record to the indicated file with Zero Entries. Will return one of the following messages in [LOGSTATUS]:
  1. "Error: " & Record & " is already registered"
  2. "Record " & Record & " registered"
$LOG: Remove all entries from record {#0} in file {#1}
0 Record Name
1 FileName
Resets the number of Entries associated with Record if said Record exists. Will return one of the following [LOGSTATUS] messages:
  1. "Record " & Record & " not found"
  2. "Log cleared for record " & Record
$LOG: Remove all logs and all records from file {#0}
0 FileName
Deletes a $LOG by writing to the file the single line of "0", or optionally creates the file with "0". Returns the [LOGSTATUS] message of "Log cleared".
$LOG: Remove log entry {#0} from record {#1} in file {#2}
0 Entry number
1 Record Name
2 FileName
Removes a specific Entry from a Record if named Record exists, and there is an Entry at position Number, base 1 indexing. Will return one of the following [LOGSTATUS] messages:
  1. Entry & Entry & not found for Record & Record
  2. Record & Record & not found
  3. Entry: & Entry & removed for Record & Record
$LOG: Remove record {#0} from file {#1}
0 Record Name
1 FileName
Zaps a Record from the file. Will return one of the following [LOGSTATUS] messages:
  1. "Record " & Record & " not found"
  2. "Record " & Record & " removed"
$LOG: Save entry {#0} to file {#1} under record {#2}
0 What to save
1 FileName
2 Record Name
This will always succeed, creating Record if Record does not exist. Will return the following [LOGSTATUS] message:
  1. "Entry saved to " & Record
$LOG: Save entry {#0} to file {#1} under record {#2} only if no entries exist
0 What to save
1 FileName
2 Record Name
This will save exactly one, and only one, Entry under a Record. Will create the Record if it doesn't exist. Will return one of the following [LOGSTATUS] messages:
  1. "Couldn't save - Record " & Record & " already contains an entry"
  2. "Entry saved to " & Record
$LOG: Save entry {#0} to file {#1} under record {#2} only if record exists
0 What to save
1 FileName
2 Record Name
Kin to above (20), this will save an Entry only if Record exists. Will return one of the following [LOGSTATUS] messages:
  1. "Record " & Record & " not found"
  2. "Entry saved to " & Record
$LOG: Set variable {#0} to contain all entries in record {#1} in file {#2}
0 Variable Name
1 Record Name
2 FileName
Fetches all the Entries under Record and stores them into Variable, delimiting the results with " -- ". If the Record does not exist, returns the message "Error: Record " & Record & " not found". If the Record contains Zero entries, will gladly return an empty string. If the results are greater than SendLimit, you will get back only SendLimit of the results.
$LOG: Set variable {#0} to contain all entries in record {#1} in file {#2} separated with {#3}
0 Variable Name
1 Record Name
2 FileName
3 Delimiter string
Like above, but allows you to use something other than the default " -- " for the delimiter.
$LOG: Set variable {#0} to contain evaluated entry {#1} from record {#2} in file {#3}
0 Variable Name
1 Entry number
2 Record Name
3 FileName
This one sounds a tad strange, but follow along. This will set the Variable to the selected Entry of Record, but before storing the return from the log function, will process it first, so if you have an entry like:
"Welcome [player] to our humble [dreamname]"
The result will replace the two variables with the appropriate values.

 

See command (30), below
$LOG: Store entry {#0} from record {#1} in file {#2} to evaluated variable {#3}

$LOG: Set variable {#0} to contain first {#1} record names starting with {#2} in file {#3}
0 Variable Name
1 Max records to return
2 Search syntax (try "a*" for example)
3 FileName
Scans FileName from top to bottom and uses the wildcard parameter in option {#2} to return a list of Record names, limiting the search to the first {#1} names found, returning the results in Variable. Use's the following terms to match names:
$LOG: Set variable {#0} to contain first {#1} record names starting with {#2} in file {#3} sorted
0 Variable Name
1 Max records to return
2 Starting syntax (try "a*" for example)
3 FileName
Like above (22), but sorts the results.
$LOG: Set variable {#0} to contain list of all record names starting with {#1} in file {#2}
0 Variable Name
1 Starting syntax (try "a*" for example)
2 FileName
Like above (23), but no limits.
$LOG: Set variable {#0} to contain list of all record names starting with {#1} in file {#2} sorted
0 Variable Name
1 Starting syntax (try "a*" for example)
2 FileName
Like above (26), but sorts.
$LOG: Set variable {#0} to contain list of record names which logs contain {#1} in file {#2}
0 Variable Name
1 Containing string (wildcards accepted / needed)
2 FileName
Like the commands (22), (23), (26), & (27), this returns a list of names based on a wildcard (or not) search of the ENTRIES in the $LOG.
$LOG: Set variable {#0} to contain list of record names which logs contain {#1} in file {#2} sorted
0 Variable Name
1 Contain string (wildcards accepted / needed)
2 FileName
Like (28) only sorts the list.
$LOG: Set variable {#0} to contain number of entries in file {#1}
0 Variable Name
1 FileName
Scans the $LOG and adds all the counts for each Record, storing the result into Variable.
$LOG: Set variable {#0} to contain number of entries in record {#1} in file {#2}
0 Variable Name
1 Record Name
2 FileName
Fetches the number of Entries entered under Record. Sets [LOGSTATUS] to one of the following:
  1. "Success"
  2. "Record " & Record & " not found"
$LOG: Set variable {#0} to contain number of entries which contain {#1} in file {#2}
0 Variable Name
1 Contain string (wildcards accepted / needed)
2 FileName
Like (28) & (29), except this returns the Count of Entries found, not a list of Record names. See (35) below.
$LOG: Set variable {#0} to contain number of records in file {#1}
0 Variable Name
1 FileName
Returns the number of Records in the file. Does not set [LOGSTATUS] in the event of an error.
$LOG: Set variable {#0} to contain number of records which entries contain {#1} in file {#2}
0 Variable Name
1 Contain string (wildcards accepted / needed)
2 FileName
Like (34), but returns the number of Records which contain the search string in one of their entries. All it has to do is match one and the Record will be counted.
$LOG: Store entry {#0} from record {#1} in file {#2} to evaluated variable {#3}
0 Entry number
1 Record Name
2 FileName
3 Evaluated Variable
Like command 30, this one does something perculiar, it runs the evaluation on the "Variable" before storing the results into it. This will cause some interesting problems if you use the "[]" around the variable! For example, you can:
$LOG: Store entry {1} from record {[player]} in file {logfile.log} to evaluated variable {[player]}
and the result will be a variable in the system whose name is the name that was contained in the variable [player]!

 

See command (24), above
$LOG: Set variable {#0} to contain evaluated entry {#1} from record {#2} in file {#3}

$LOG: Update entry {#0} from record {#1} in file {#2} to contain {#3} (record / entry must exist)
0 Entry number
1 Record Name
2 FileName
3 New content to store
This will replace EntryNumber with New Content under Record in FileName. Will set [LOGSTATUS] to one of the following:
  1. "Record data updated"
  2. "Entry " & EntryNumber & " not found in record " & Record
  3. "Record " & Record & " not found"
Last Updated ( Feb 20, 2010 at 10:15 PM )
<Previous   Next>
header image