# CommandOutputParameter - mathematical evaluation and assignment

**URL:** <https://cwl.discourse.group/t/commandoutputparameter-mathematical-evaluation-and-assignment/310>\
**Category:** CWL Questions\
**Created:** [February 15, 2021, 12:32am UTC](https://cwl.discourse.group/t/commandoutputparameter-mathematical-evaluation-and-assignment/310 "2021-02-15T00:32:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nicholas\_Yue](https://yyz2.discourse-cdn.com/free1/user_avatar/cwl.discourse.group/nicholas_yue/32/95_2.png) [@Nicholas\_Yue](https://cwl.discourse.group/u/Nicholas_Yue)\
**Post date:** [February 15, 2021, 12:32am UTC](https://cwl.discourse.group/t/commandoutputparameter-mathematical-evaluation-and-assignment/310/1 "2021-02-15T00:32:17Z")

</div>

I have some output parameter of type int which I’d like to provide to downstream steps, how can I perform numerical evaluation for output parameter. Currently, my evaluation result in string rather than actual integer maths.

```auto
def main(cwlFile):
    clt = cwl.CommandLineTool(
        successCodes=[0],
        arguments=["--background", "--python", "$(inputs.blenderScript.path)",
                   "--", "--input", "$(inputs.inputAlembicMesh)",
                   "--output", "$(inputs.alembicCamera)",
                   "--start", "$(inputs.start)",
                   "--frames", "$(inputs.frames)"],
        requirements=[cwl.InlineJavascriptRequirement()],
        baseCommand="blender",
        inputs=[
            cwl.CommandInputParameter("File", id="blenderScript"),
            cwl.CommandInputParameter("string", id="inputAlembicMesh"),
            cwl.CommandInputParameter("string", id="alembicCamera"),
            cwl.CommandInputParameter("int", id="start"),
            cwl.CommandInputParameter("int", id="frames"),
        ],
        outputs=[
            cwl.CommandOutputParameter("string", id="outputAlembicCamera", outputBinding={
                                       "outputEval": "$(inputs.alembicCamera)"}),
            cwl.CommandOutputParameter("int", id="renderStart", outputBinding={
                                       "outputEval": "$(inputs.start)"}),
            cwl.CommandOutputParameter("int", id="renderEnd", outputBinding={
                                       "outputEval": "$(inputs.frames) - 1"}),
            cwl.CommandOutputParameter("int", id="renderStep", outputBinding={
                                       "outputEval": "1"})
        ]
    )

    dict_representation = clt.save()
    dict_representation['cwlVersion'] = 'v1.0'
    yaml = YAML()
    with open(cwlFile, 'w') as outfile:
        yaml.dump(dict_representation, outfile)

```

---

<div class="post-metadata">

**Author:** ![Nicholas\_Yue](https://yyz2.discourse-cdn.com/free1/user_avatar/cwl.discourse.group/nicholas_yue/32/95_2.png) [@Nicholas\_Yue](https://cwl.discourse.group/u/Nicholas_Yue)\
**Post date:** [February 15, 2021, 2:26am UTC](https://cwl.discourse.group/t/commandoutputparameter-mathematical-evaluation-and-assignment/310/2 "2021-02-15T02:26:34Z")

</div>

Answering my own question, the following seems to be working so I will go with this

i.e. using the JavaScript parseInt() function

```auto
        outputs=[
            cwl.CommandOutputParameter("string", id="outputAlembicCamera", outputBinding={
                                       "outputEval": "$(inputs.alembicCamera)"}),
            cwl.CommandOutputParameter("int", id="renderStart", outputBinding={
                                       "outputEval": "$(inputs.start)"}),
            cwl.CommandOutputParameter("int", id="renderEnd", outputBinding={
                                       "outputEval": "$(parseInt(inputs.frames) - 1)"}),
            cwl.CommandOutputParameter("int", id="renderStep", outputBinding={
                                       "outputEval": "$(parseInt(\"1\"))"})
        ]

```

---

<div class="post-metadata">

**Author:** ![tetron](https://yyz2.discourse-cdn.com/free1/user_avatar/cwl.discourse.group/tetron/32/40_2.png) [@tetron](https://cwl.discourse.group/u/tetron)\
**Post date:** [February 15, 2021, 3:55pm UTC](https://cwl.discourse.group/t/commandoutputparameter-mathematical-evaluation-and-assignment/310/3 "2021-02-15T15:55:47Z")

</div>

> [@Nicholas\_Yue](#):
>
> ```auto
> cwl.CommandOutputParameter("int", id="renderStep", outputBinding={
> "outputEval": "1"})
> 
> ```

I think this would work too, just don’t quote the value of `1`:

```auto
            cwl.CommandOutputParameter("int", id="renderStep", outputBinding={
                                       "outputEval": 1})

```
