I want to create some kind of procedure like thing on the client side, which manipulates various variable values, and then I want to call it under certain conditions, such as when a button is clicked.
For those Bubblers amongst you, this would be the same as creating a Custom Event in Bubble.
Then just use the dynamic events for this.
You can set several actions to be run on specific dynamic event (depending on the element). They will all be run when this event is triggered.
You could create a javascript function and call that. Search the forum for dmx.parse and dmx.app and you will probably find some examples of how to connect the two.