Indigo Rose Software

Professional Software Development Tools

 
+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    May 2006
    Posts
    16

    Is there an eval() command?

    Is there a way to execute code that is stored in a string in AMS?

    Currently I can write the string to a file and then run the file like:

    Code:
    myScript="Debug.ShowWindow(true);Debug.Print('Hello World');"
    myLocation="C:\\MyFile.lua"
    TextFile.WriteFromString(myLocation, myScript, false);
    Application.RunScriptFile(myLocation);
    or I can assign it to a hotspot and then execute the on click event like:

    Code:
    myOtherScript="Debug.ShowWindow(true);Debug.Print('Goodbye World');"
    Page.SetObjectScript("MyHotspot", "On Click", myOtherScript);
    Page.ClickObject("MyHotspot");
    Is it possible to just do some type of eval(myScript)?

    This would be used with pulling scripts from a MYSQL/SQLLITE DB and then executing them. They would all be valid Lua Scripts.

  2. #2
    Join Date
    Sep 2002
    Location
    Sol 3
    Posts
    3,160
    There is dofile() and require().

    Here is the online help file
    http://www.indigorose.com/webhelp/am...m#_Toc47928356
    TJ-Tigger
    "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
    "Draco dormiens nunquam titillandus."
    Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

  3. #3
    Join Date
    Oct 2007
    Location
    Gensokyo
    Posts
    1,324
    Quote Originally Posted by TJ_Tigger View Post
    There is dofile() and require().

    Here is the online help file
    http://www.indigorose.com/webhelp/am...m#_Toc47928356
    Then again.

    Code:
    local sCode = "Dialog.Message(\"HAI THAR\", \"What's up people.\");";
    
    loadstring(sCode)()
    eval = loadstring, You need the () at the end as well, If you want to catch the error do this.

    Code:
    local sCode = "broken_code()";
    
    local function RunString(sString) return loadstring(sString)(); end
    
    ret, err = pcall(RunString, sCode);
    
    if (err) then
          Dialog.Message("OH SHI-", "An error occured, Blah blah blah.\r\n\r\n\t"..err.."\r\n\r\nWe recommend you do nothing and moan about it.");
    end

  4. #4
    Join Date
    May 2006
    Posts
    16
    Quote Originally Posted by ShadowUK View Post
    Then again.

    Code:
    local sCode = "Dialog.Message(\"HAI THAR\", \"What's up people.\");";
    
    loadstring(sCode)()
    eval = loadstring, You need the () at the end as well, If you want to catch the error do this.

    Code:
    local sCode = "broken_code()";
    
    local function RunString(sString) return loadstring(sString)(); end
    
    ret, err = pcall(RunString, sCode);
    
    if (err) then
          Dialog.Message("OH SHI-", "An error occured, Blah blah blah.\r\n\r\n\t"..err.."\r\n\r\nWe recommend you do nothing and moan about it.");
    end
    Thank you - exactly what i was looking for

Similar Threads

  1. Windows Command Line Library
    By sside in forum AutoPlay Media Studio 5.0
    Replies: 0
    Last Post: 08-19-2006, 10:49 AM
  2. Function: Parsing Command Line Arguments
    By Brett in forum AutoPlay Media Studio 5.0 Examples
    Replies: 0
    Last Post: 05-13-2004, 08:42 AM
  3. HOWTO: AutoPlay Media Studio 4.0 and Flash Interaction
    By Support in forum AutoPlay Media Studio 4.0 Examples
    Replies: 0
    Last Post: 10-30-2002, 10:40 AM
  4. HOWTO: Build a Setup from the Command Line
    By Support in forum Setup Factory 5.0
    Replies: 0
    Last Post: 10-08-2002, 01:43 PM
  5. HOWTO: Build a Setup from the Command Line
    By Support in forum Setup Factory 6.0 Knowledge Base
    Replies: 0
    Last Post: 09-27-2002, 02:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts