Page 1 of 1

Text as a expression variable within Resolve's Fusion tab

PostPosted: Sun Oct 07, 2018 9:29 am
by Andy Mees
Hi All

I've been fumbling around a bit lately, hoping to figure out the extents of what I can and can't get my head around with expressions in Fusion (as opposed to what actually possible). I'm getting there... but very slowly!

Today I've been trying my luck with a very simple text handling expression attached to a StyledText field of a Text+ tool (which I've named in my flow as 'displayText') ... my goal being to see if I could force a simple text wrap based on a max character limit.

My trial StyledText expression, where I manually define my input string (inputStr) and character limit (maxChars) is as follows:
Code: Select all
:inputStr = "The quick brown fox jumps over the lazy dog";
maxChars = 20;
inputLen = string.len(inputStr);
return (inputLen>maxChars) and (string.sub(inputStr,1, maxChars).."\n"..string.sub(inputStr, maxChars, inputLen)) or (inputStr)

And the above displays (and wraps) exactly as expected, so the next step was to add custom inputs.

First I added a CustomTool (called 'customInputs') to the comp.
Then I replaced the value for maxChars in my StyledText expression with a number from customInputs:
Code: Select all
:inputStr = "The quick brown fox jumps over the lazy dog";
maxChars =floor(customInputs.NumberIn1);
inputLen = string.len(inputStr);
return (inputLen>maxChars) and (string.sub(inputStr,1, maxChars).."\n"..string.sub(inputStr, maxChars+1, inputLen)) or (inputStr)

Again, that worked great, manipulating the control allows me to dynamically change the wrap...

So next I added a second Text+ instance (which I called 'inputText').
And replaced the value for inputStr in my (displayText) StyledText expression with the StyledText value from inputText:
Code: Select all
:inputStr =inputText.StyledText;
maxChars =floor(customInputs.NumberIn1);
inputLen = string.len(inputStr);
return (inputLen>maxChars) and (string.sub(inputStr,1, maxChars).."\n"..string.sub(inputStr, maxChars+1, inputLen)) or (inputStr)

But that seems to have killed it. It all seemed to be making sense right up to that last step.

I've been digging around trying to figure out why that last step didn't work but am coming up short. Whenever I define my variable inputStr using a control, like 'inputText.StyledText', and pass it straight through the expression without manipulating it, then it displays fine:
Code: Select all
:inputStr =inputText.StyledText;
return inputStr

... but as soon as I try to use any 'string' functions on inputStr (after defining its value from a control) it fails immediately:
Code: Select all
:inputStr =inputText.StyledText;
inputLen = string.len(inputStr);
return inputLen


Yet the exact same code worked fine when I defined the variable manually.
Can anyone help point out the error of my ways? I'd much appreciate it.

Cheers
Andy

Re: Text as a expression variable within Resolve's Fusion ta

PostPosted: Sun Oct 07, 2018 11:29 am
by Okke Verbart
Try this:

Code: Select all
inputText.StyledText.Value


instead of

Code: Select all
inputText.StyledText

Re: Text as a expression variable within Resolve's Fusion ta

PostPosted: Sun Oct 07, 2018 11:50 am
by Andy Mees
Thanks Okke, that works ... and makes sense!

And many many more thanks for your 'blackbirdcalledsue' tutorials... I've been watching them a lot over the last few days. They are superb!

Re: Text as a expression variable within Resolve's Fusion ta

PostPosted: Sun Oct 07, 2018 11:59 am
by Okke Verbart
Glad it worked out Andy :-)

And thanks so much for your kind comments!