Script

Access protocols variables example

Publication ID: ICY-85945

Short Description

This script quickly shows how to retrieve all block descriptors from a (loaded) protocol and how to retrieve output variable value

Versions

  • Version 1 • Released on: 2021-08-31 18:00:00
    Download
    Description:

    Initial version

    importClass(Packages.plugins.adufour.blocks.lang.BlockDescriptor)
    importClass(Packages.plugins.adufour.protocols.Protocols)
    
    mf = Protocols.getInstance()
    proto = mf.getActiveProtocol()
    workflow = proto.getWorkFlow()
    
    // get all blocks from workflow
    blocks = workflow.getBlockDescriptors(true)
    
    // we want only output variable blocks
    //blocks = workflow.getOutputBlockDescriptors(true)
    
    // find output variable block with given command line id (work ame as input block)
    out_block = BlockDescriptor.findOutputBlockDescriptor("text out", blocks)
    // handy function to quickly return variable of single variable block
    out_var = out_block.getVariable()
    
    if (out_var != null)
    	println("Output var value = " + out_var.getValueAsString())
    
    for(i = 0; i < blocks.size(); i++)
    {
    	block = blocks.get(i)
    	println(block.getName() + " - " + block.getID() + " - " + block.getCommandLineID())
    
    	v = block.getVariable()
    	if (v != null)
    		println("    value = " + v.getValueAsString())
    }
    

Leave a Review