Difference between revisions of "EOF"

From Second Life Wiki
Jump to navigation Jump to search
Line 9: Line 9:
|notes=EOF is an acronym that stands for "End Of File".
|notes=EOF is an acronym that stands for "End Of File".
|examples=
|examples=
<lsl>integer iLine;
<lsl>
string card = "~config"
integer nline;
key myquery;
string card;
 
key query;
default{
list notedata;
     state_entry() {
default
{
     state_entry()  
    {
        card=llGetInventoryName(INVENTORY_NOTECARD,0);
         if(llGetInventoryType(card) != INVENTORY_NONE)
         if(llGetInventoryType(card) != INVENTORY_NONE)
             myquery = llGetNotecardLine(card, iLine = 0);
        {
         else
             query = llGetNotecardLine(card, nline = 0);
            llSay("The \"" + card + "\" notecard is missing! Cannot proceed!");
         }
     }
     }
   
     dataserver(key request, string sdata){
     dataserver(key queryid, string data)
         if(request == myquery){
    {
             if(sdata == EOF){ // no more text in the notecard
         if(queryid == query)
                 state ready; //move to the next state
        {
             if(data == EOF)
            {  
                 llOwnerSay(llDumpList2String(notedata,"\n"));  
             }
             }
             else {
             else  
                 //here you would process the data
            {
                //llOwnerSay(sdata);
                 notedata+=[data];
                 myquery = llGetNotecardLine(card, ++iLine); // now read in next line, and start the dataserver process all over again
                 query = llGetNotecardLine(card, ++nline);
             }
             }
         }
         }
    }
}
state ready{
    state_entry(){
        llOwnerSay("I'm ready for action!");
     }
     }
}
}

Revision as of 07:34, 25 July 2009

Description

Constant: string EOF = "\n\n\n";

The string constant EOF has the value "\n\n\n"

EOF is a value returned by the dataserver event, as a result of a call to llGetNotecardLine, specifically when the requested line is past the end of the notecard. The value returned equals "\n\n\n", which is to say, three newline characters (0x0a).

Essentially, it is used to let you know when you have finished reading information (usually user configurable parameters) from a notecard, and are ready to move onto the next stage or state of the script.

Caveats


Related Articles

Functions

•  llGetNotecardLine

Events

•  dataserver

Examples

<lsl> integer nline; string card; key query; list notedata;

default {

   state_entry() 
   {
       card=llGetInventoryName(INVENTORY_NOTECARD,0);
       if(llGetInventoryType(card) != INVENTORY_NONE)
       {
           query = llGetNotecardLine(card, nline = 0);
       }
   }

   dataserver(key queryid, string data)
   {
       if(queryid == query)
       {
           if(data == EOF)
           { 
               llOwnerSay(llDumpList2String(notedata,"\n")); 
           }
           else 
           {
               notedata+=[data];
               query = llGetNotecardLine(card, ++nline);
           }
       }
   }

} </lsl>

Notes

EOF is an acronym that stands for "End Of File".

Deep Notes

Search JIRA for related Issues

Signature

string EOF = <span title="Three newline characters (0x0a)" style="border-bottom:1px dotted; cursor:help;">"\n\n\n"</span>;