Message Image  

Rocket LegaSuite & API

Expand all | Collapse all

LEGASUITE WINDOWS CLIENT CRASHES WHEN USING SCRIPTEXEC() FOR FUNCTION SCRIPT TYPE

Jump to Best Answer
  • 1.  LEGASUITE WINDOWS CLIENT CRASHES WHEN USING SCRIPTEXEC() FOR FUNCTION SCRIPT TYPE

    Posted 03-26-2021 07:39

    Product: Legasuite Windows Client (NOT THE WEB EDITOR)

    I am having issues using the ScriptExec() function for creating user functions. I have been successful in using it to run scripts (script_type 0) and creating structures (script_type 1), but when using it to create User Defined Functions (script_type 2 according to the documentation) it crashes the client window when a call to the function is made. I have tried it both with loading the function from a file and running it directly from a variable. I have tried the most basic of functions and example functions from the documentation. All give the same result.

    I am wondering why this crashes on functions but scripts and structures work without issue. I have looked through all of the documentation on the ini settings and did not find anything relating to user defined functions. Is there an undocumented ini setting or some flag that needs to be set to allow user defined functions?

    Here is my test script using an example function from the scripting documentation:

    Dim i as integer
    Dim s, f as string

    f = "Function MyHelloWorldTest(i as integer) as string" + chr(13) + "MyHelloWorldTest = Str(i)" + chr(13) + "End function"
    ScriptExec(f,2) ' Run string f as function using option 2

    i = 42
    Messagebox("Show Function",f,4,0) ' Verifies program still running at this point and no errors in function definition

    s = MyHelloWorldTest(i) ' Program crashes as soon as the function is called

    Messagebox("MyHelloWorldTest",s,4,0) ' Never runs because program crashes



    ------------------------------
    Nick Dunevant
    Charter Communications
    ------------------------------


  • 2.  RE: LEGASUITE WINDOWS CLIENT CRASHES WHEN USING SCRIPTEXEC() FOR FUNCTION SCRIPT TYPE

    Posted 03-26-2021 07:50
    Hi Nick,

    I am currently reviewing the example you've provided and will post an update shortly.

    Thanks, Sarah

    ------------------------------
    Sarah Gerards-Gilbert
    Rocket Software
    ------------------------------



  • 3.  RE: LEGASUITE WINDOWS CLIENT CRASHES WHEN USING SCRIPTEXEC() FOR FUNCTION SCRIPT TYPE

    ROCKETEER
    Posted 03-26-2021 07:55
    Hi Nick,

    What version are you using?

    When I copy and paste your script into a test.script file, then execute this from a button (using an OIS object) then I get two message boxes.
    The first one showing the script function, and the second showing the answer to everything: 42.

    I have been using our latest GA version 8.5.5 for this test, using a windows client live test.

    If you are on an older version you could try this in 8.5.5. If the problem persists in there it will be best to report this in a case through the customer portal so we can reproduce the problem here in the lab to fix this.


    ------------------------------
    Roger van Valen
    Rocket Software
    ------------------------------



  • 4.  RE: LEGASUITE WINDOWS CLIENT CRASHES WHEN USING SCRIPTEXEC() FOR FUNCTION SCRIPT TYPE

    Posted 03-26-2021 08:22
    If I recall correctly the version is currently 7.6.2.
    However, the method for calling the ScriptExec, which Nick is using, is initiated through a macro (external script) on the Windows Client.
    When testing, I find that the Client session terminates on script execution.
    Roger and I are investigating this further.

    ------------------------------
    Sarah Gerards-Gilbert
    Rocket Software
    ------------------------------



  • 5.  RE: LEGASUITE WINDOWS CLIENT CRASHES WHEN USING SCRIPTEXEC() FOR FUNCTION SCRIPT TYPE

    Posted 03-26-2021 08:57
    Hi Nick,

    I've generated a support ticket for this case as it will need to be addressed via our lab for an upcoming release.
    I'll post additional updates to you through that case.

    Thank you for bringing this to our attention.

    Sarah

    ------------------------------
    Sarah Gerards-Gilbert
    Rocket Software
    ------------------------------



  • 6.  RE: LEGASUITE WINDOWS CLIENT CRASHES WHEN USING SCRIPTEXEC() FOR FUNCTION SCRIPT TYPE

    Posted 03-26-2021 09:11

    Sarah is correct, I am using the Windows Client version 7.6.2. I am aware it is an older version, but it is what my company requires us to use at this time.

    ScriptExec() is being ran from a script within the Legasuite Windows Client "Open Script" menu. My intention is to have the function in an external script, load it into a variable via the FileLoad() function and use ScriptExec() to run it. I use this same process for scripts and structures which work perfectly. However, the example was run directly from the a built in script (nothing external) and still crashes the Client.



    ------------------------------
    Nick Dunevant
    Charter Communications
    ------------------------------



  • 7.  RE: LEGASUITE WINDOWS CLIENT CRASHES WHEN USING SCRIPTEXEC() FOR FUNCTION SCRIPT TYPE
    Best Answer

    ROCKETEER
    Posted 03-26-2021 11:12
    Thanks Nick,

    That gives me a better understanding of what you want to achieve.

    The scripts that can be created in the windows client are actually stored as separate script files. In that way they are 'external' scripts to the windows client as they are not included in the package files (*.lwr, which holds the screen, panel, script and other files). 

    When I use the example script and implement this through the workbench in the package file, it does seem to work as expected.
    But when it is used in a script executed from the windows client saved scripts/macro's it will not. This is what you are experiencing.

    We have created a ticket to fix that in a future release.

    As alternative you can use regular scripts instead of script functions. Global variables can be used as replacement for script function arguments. 
    This would allow you to do the things you need to do, just in a slightly different way.

    For example using:

    Global Param_i as integer
    Dim s, f as string
    
    f = "Global ResultValue as string" + chr(13) + "ResultValue = Str(Param_i)" 
    
    Param_i = 42
    Messagebox("Show Function",f,4,0) ' Verifies program still running at this point and no errors in function definition
    
    ScriptExec(f,0) ' Run string f as script using option 0
    
    Messagebox("MyHelloWorldTest",ResultValue,4,0) 
    ​

    Hope this helps,
    Regards,
    Roger.

    ------------------------------
    Roger van Valen
    Rocket Software
    ------------------------------



  • 8.  RE: LEGASUITE WINDOWS CLIENT CRASHES WHEN USING SCRIPTEXEC() FOR FUNCTION SCRIPT TYPE

    Posted 03-26-2021 14:01
    Sarah, thank you for creating a ticket for this. I was hoping it was just a setting or something that I was unaware of and could fix immediately. It is unfortunate that it is a bug. Oh, well. I will continue to use my work around for it.

    Roger, Thank you for the suggestion with the global variables. That is exactly how I have been working around not having functions so far. Having the ability to create actual functions would be more efficient though, so I was hoping for that.

    I thank you both for your assistance.

    ------------------------------
    Nick Dunevant
    Charter Communications
    ------------------------------



  • 9.  RE: LEGASUITE WINDOWS CLIENT CRASHES WHEN USING SCRIPTEXEC() FOR FUNCTION SCRIPT TYPE

    ROCKETEER
    Posted 04-12-2021 06:56
    Hi Nick,

    I just wanted to let you know that the fix for this issue will be available in our Q3 release.

    Speaking of releases, I noticed you are still on LegaSuite 7.6.2? That version was released in May 2016 and we have added a lot of new functionality and security(!) benefits since then that your organisation might not be aware of?
    Please let me know if we can provide more details on that? 

    Thanks,

    ------------------------------
    Jeroen van Dun
    Rocket Software
    ------------------------------