Jump to content
  • How to Execute an IronPython Script with Multiple Input Parameters from within Another IronPython Script in Spotfire®


    This article provides a code sample of how to Execute an IronPython Script with Multiple Input Parameters from within Another IronPython Script in Spotfire®

    Introduction

    It is possible to execute an IronPython script from within another IronPython script. If the script requires multiple input parameters then you must pass those parameters in the script as well.

    The input parameters are defined as a comma separated list of "name:value" parameters. For example:

     params = {'MyInputVis':visual,'MyInputString':'Hello world!'}
     

    where the name values ('MyInputVis' and 'MyInputString' in the example above) matches the name of the input parameters defined for the script which you are calling. The object/value passed must match the data type (Visualization, Page, Data Table, String, etc.) of the input parameter.

    Here is an example which executes a script called 'MyScript', which takes multiple input parameters as defined above.

    Code Sample

    # Copyright © 2018. TIBCO Software Inc. Licensed under TIBCO BSD-style license.
    
    from System.Collections.Generic import Dictionary
    from Spotfire.Dxp.Application.Scripting import ScriptDefinition, ScriptParameterType as type
    
    found, scriptDef = Document.ScriptManager.TryGetScript('MyScript')
    visual = Document.ActivePageReference.ActiveVisualReference
    
    if found:
        for param in scriptDef.Parameters:
            print param.Name
            print param.Description
    
        params = {'MyInputVis':visual,'MyInputString':'Hello world!'}
        try:
            Document.ScriptManager.ExecuteScript(scriptDef, params)
        except:
            print 'Error has occurred.'
     

    References

    License:  TIBCO BSD-Style License

     

     


    User Feedback

    Recommended Comments

    There are no comments to display.


×
×
  • Create New...