Search code examples
pythonbooggie

How to return multiple strings from a script to the rule sequence in booggie 2?


This is an issue specific to the use of python scripts in booggie 2.

I want to return multiple strings to the sequence and store them there in variables.

The script should look like this:

def getConfiguration(config_id):
    """ Signature:  getConfiguration(int): string, string"""

    return "string_1", "string_2"

In the sequence I wanna have this:

(param_1, param_2) = getConfiguration(1)

Please note: The booggie-project does not exist anymore but led to the development of Soley Studio which covers the same functionality.


Solution

  • Still, it's not possible to return multiple values but a python list is now converted into a C#-array that works in the sequence.

    The python script itself should look like this

    def getConfiguration(config_id):
        """ Signature:  getConfiguration(int): array<string>"""
    
        return ["feature_1", "feature_2"]
    

    In the sequence, you can then use this list as if it was an array:

    config_list:array<string>               # initialize array of string
    (config_list) = getConfigurationList(1) # assign script output to that array
    
    {first_item = config_list[0]}           # get the first string("feature_1") 
    {second_item = config_list[1]}          # get the second string("feature_2")