ZBrushCentral

How to return values from "RoutineCall"?

I’m trying to define a string equality function:

[RoutineDef, StrEquals,
[note, s1]
[if, ([StrLength, s1] == [StrLength, s2]) && ([StrFind, s1, s2] == 0),
1,
0
],
s1, s2
]
[if, [RoutineCall, StrEquals, “hello”, “hello”],
[note, “hello”]]

The second command should hopefully put up a note saying “hello” on the screen. But the script fails to parse.

Basically, StrEquals is supposed to return either a 1 or a 0, depending on whether or not its string arguments are equal.

Can anyone help with this?

Thanks,
Ken

Pass a third variable to your routine - have the routine set the variable appropriately and return it. Then If test the returned value…

Sven

Another way is to have a global variable defined. Adjust that variable in the [RoutineDef,…].

Variables declared outside of containers (IButton, ISlider, RoutineDef, etc.) are global variables and are accessible throughout the zscript at any time. A variable declared inside a container is first accessible when the container has been activated.

Usualy you assign global variables by [VarDef,…]'ing them at the start of the zscript for easy access when editing but also to avoid errors when using an [If,…] or [Sleep,…] command outside a container. When a zscript is loaded it is interpreted linearly, from top to bottom. If an [If,…] or [Sleep,…] command outside a container relies on variables being already defined you should put them at the end of your Zscript.

All the commands outside of containers can be seen as belonging to a container themselves, the global container, and as such must adhere to the same variable availability rule as containers do.

Svengali: You have mail.... in about 10 minutes time.

I’d do it like this:


[VarDef,i,0]

[RoutineDef, StrEquals,
[Note, s1]

[if, ([StrLength, s1] == [StrLength, s2]) && ([StrFind, s1, s2] == 0),
[VarSet,i,1],
[VarSet,i,0]
],
s1, s2,
]


[RoutineCall, StrEquals, "hello", "hello"]
[if,i=1,
[note, "string found"]]