http://agiwiki.sierrahelp.com//index.php?title=Log&feed=atom&action=historyLog - Revision history2024-03-28T15:34:38ZRevision history for this page on the wikiMediaWiki 1.35.9http://agiwiki.sierrahelp.com//index.php?title=Log&diff=12479&oldid=prevAndrew Korson: Created page with "The '''log''' command adds an entry to the game's log file. == Syntax == log(msg mLOGMSG);<br /> log("log message"); == Remarks == The '''log''' command is oft..."2019-04-11T18:22:00Z<p>Created page with "The '''log''' command adds an entry to the game's log file. == Syntax == log(<a href="/index.php/Message" title="Message">msg</a> mLOGMSG);<br /> log("log message"); == Remarks == The '''log''' command is oft..."</p>
<p><b>New page</b></p><div>The '''log''' command adds an entry to the game's log file.<br />
<br />
== Syntax ==<br />
<br />
log([[message|msg]] mLOGMSG);<br /><br />
log("log message");<br />
<br />
== Remarks ==<br />
<br />
The '''log''' command is often used during [[AGI Debugging Information|debugging]] of games. It allows the programmer to capture some basic information and save it to a file that can later be examined to make corrections and improvements to a game.<br />
<br />
If the game's log file (named 'logfile') does not exist in the game's directory, it will be automatically created. If the file already exists, the log entry is appended to the existing file.<br />
<br />
The logfile entry is written in three lines, in the following format:<br /><br />
<CODE>Room <#><br /><br />
Input line: <text><br /><br />
<message></CODE><br /><br />
The [[room]] number is the current value if [[reserved variable]] [[v0]]. The input line value is the most recent line of text that was entered on the [[input line]]. The text of [[message]] '''mLOGMSG''' is added as the last line.<br />
<br />
If AGI encounters any file errors while trying to open or write to the logfile, it just ignores the errors, and does not write the log file entry.<br />
<br />
== Possible Errors ==<br />
<br />
None.<br />
<br />
== Example ==<br />
<br />
<div class="CodeBlockHeader">Code:</div><br />
<syntaxhighlight lang="agi"><br />
[ commonly used entry to track which words players are <br />
[ using in a game; can help improve the WORDS.TOK file<br />
if (!isset(haveMatch) && isset(haveInput) && unknownWord > 0) <br />
{<br />
set(haveMatch);<br />
reset(haveInput);<br />
if (unknownWord == 1)<br />
{<br />
log("Unknown word: %w1");<br />
}<br />
...<br />
[ repeat for the other possible word numbers<br />
...<br />
if (unknownWord == 10) <br />
{<br />
log("Unknown word: %w10");<br />
}<br />
<br />
print("Logged an unknown word.");<br />
}<br />
</syntaxhighlight><br />
<br />
== Technical Information ==<br />
<br />
{| border="1" cellpadding="2"<br />
| style="background-color: #efefef" width="200" | '''Required Interpreter Version:'''<br />
| width="175" | Available in all AGI versions.<br />
|-<br />
| style="background-color: #efefef" | '''Byte-Code Value:'''<br />
| 144 (0x90 hex)<br />
|}<br />
<br />
== See Also ==<br />
<br />
[[Debugging Commands]]<br /><br />
[[AGI Debugging Information]]<br /><br />
[[Category:Commands]]<br /></div>Andrew Korson