Call functions from a Manipulate?

I have a working graphic representation of a velocity profile between two velocities.

It uses Manipulate to adjust various parameters and this calls a few functions defined in the same scope.

When I publish this it fails to work. The output appears to show the text of every function call rather than their results.

See https://www.wolframcloud.com/env/gilesknap/Published/VelocityProfileExample.nb

What am I doing wrong?

Thanks, giles.

Hi Giles,

Try adding SaveDefinitions -> True as an option to Manipulate.

Thanks for the suggestion. I’m afraid this had no effect.

More information. If I publish using CloudDepoly on the output cell then all is well. It is when I use the publish button to publish the whole workbook that I get the issue.

SaveDefinitions -> True should do the trick, usually, but sometimes it’s more reliable to use the Initialization option of Manipulate to make sure all necessary definitions are made before the Manipulate tries to run.

Example from the documentation:

Manipulate[f[x], {x, 0, 6}, 
    Initialization :> (
        f[z_] := Range[z]
    )
]

Thanks. Still no joy.

Here is my published workbook with the changes you suggest, still showing the issue.
https://www.wolframcloud.com/obj/gilesknap/Published/work.nb

I feel that I’m misunderstanding something about the scoping of functions.

How scope is handled is the most unfamiliar aspect of wolfram language for a long term C++, Python programmer!

I don’t see any issue with SaveDefinitions -> True.
https://wolframcloud.com/obj/damanjits/Published/CloudPublishManipulate.nb

If you include the a=2 definition in the Initialization and set SaveDefinitions -> True, it should work, I think. Unfortunately I don’t have time right now to give a better explanation than that, but I hope it works. You can always try to make the Manipulate in a notebook and see if it keeps working if you quit the kernel.