- Posts: 3259
- Joined: Wed Aug 22, 2012 7:48 am
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:
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:
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:
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:
... but as soon as I try to use any 'string' functions on inputStr (after defining its value from a control) it fails immediately:
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
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