Difference between revisions of "LlEval"

From Second Life Wiki
Jump to navigation Jump to search
Line 8: Line 8:




== It would be great to execute outsourced Code where stored in a string. ==
{{LSL_Function
 
|func=llEval
integer llEval(string code); - Should return -1, 0, 1
|func_id
 
|func_sleep=0.0
 
|func_energy=0.0
llEval() returns "0" unless return is called in the evaluated code, in which case the value passed to return is returned. If there is a parse error in the evaluated code, llEval() returns "-1" and execution of the following code continues normally.
|func_desc=
 
|func_footnote
Why ?
|return_type=integer
 
|return_text=to see the success of eval´d code.<br> -1 = Parse error in Eval´d code <br>0  = Success, but without return in Eval´d code
The first answer is : Make sure you can update your items everytime.
|p1_type=string|p1_name=code|p1_desc=a string with different LSL-functions|p1_hover
 
|constants=
Second answer: Prevent Copybots from stealing your code
|spec
 
|caveats
Third answer: Use minimal Disk usage on LL-Servers for LSL-Code ;)
|examples=
 
Fourth ...
 
 
OutSourced Code (Notecard, external Homepage, ...) :
<php>
<?php
$test = $_GET['vari'];
echo urlencode("llSetText(\"Hello $test\",<1,1,1>,1); llOwnerSay(\"Thanks for your attention\");");
?>
</php>
 
...and the inworld code :
 
<lsl>
<lsl>
key http_request_id;
default
default
{
{
     state_entry()
     state_entry()
     {
     {
         http_request_id = llHTTPRequest("http://my.testdomain.lan?vari=ANSI%20Soderstrom", [], "");
         string code = "llOwnerSay(\"Hello World\")";
    }
         if( llEval(code) != -1 )
    http_response(key request_id, integer status, list metadata, string body)
    {
         if (request_id == http_request_id && status == 200)
         {
         {
             if(~llEval(llUnescapeURL(body))) {
             llOwnerSay("...it works !!! Try now more complex :");
              llOwnerSay("Back to normal Operations...");
             llOwnerSay((string)llEval("llOwnerSay(\"Must be 23 : \"); return 23;"));
              return;
             }
            llOwnerSay("Error in Eval´d code...");
         }  
         }  
         llOwnerSay("Something goes wrong...");
         else
        {
            llOwnerSay("Parse Error in Eval´d code");
        }
     }
     }
    // Output :
    // Hello World
    // ...it works !!! Try now more complex :
    // Must be 23 : 23
}
}
</lsl>
</lsl>
 
|helpers
See and Vote for this : {{Jira|SVC-1671}}
|also_header
|also_functions
|also_tests
|also_events
|also_articles
|also_footer
|notes={{Jira|SVC-1671}}
|mode=request
|deprecated
|location
|cat1
|cat2
|cat3
|cat4
|cat5
|cat6
}}

Revision as of 10:34, 24 April 2010





Emblem-important-yellow.png LSL Feature Request
The described function does not exist. This article is a feature request.

Summary

Function: integer llEval( string code );
REQUEST Function ID
0.0 Forced Delay
0.0 Energy

Returns an integer to see the success of eval´d code.
-1 = Parse error in Eval´d code
0 = Success, but without return in Eval´d code

• string code a string with different LSL-functions

Examples

<lsl> default {

   state_entry()
   {
       string code = "llOwnerSay(\"Hello World\")";
       if( llEval(code) != -1 )
       {
           llOwnerSay("...it works !!! Try now more complex :");
           llOwnerSay((string)llEval("llOwnerSay(\"Must be 23 : \"); return 23;"));
       } 
       else
       {
           llOwnerSay("Parse Error in Eval´d code");
       }
   }
   // Output :
   // Hello World
   // ...it works !!! Try now more complex :
   // Must be 23 : 23

}

</lsl>

Notes

Deep Notes

Search JIRA for related Issues

Signature

//function integer llEval( string code );