0 votes
by (2.4k points)

Hello there, is there a way to use a widget within a widget ? It gets me issues whenever I try to do stuff like 


<<chat '$name' '$mName'

$name 'Hello <<sheS 'you' '$mName'>> 
$mName 'Hello !'



<<chat>> is a widget that simulates a messenger kind of like conversation, while <<sheS>> is a widget that checks a variable to determine what to write.
The issue is those " ' " used within both widget, <<chat>> interprets sheS's " ' " as being part of its own sent arguments. Any way to go around that ? 

Thanks a lot ! 

2 Answers

0 votes
by (159k points)
selected by
Best answer

Your issue is a result of you trying to use single quotes to act as both the delimited of the following <<chat>> arguement..

'Hello <<sheS 'you' '$mName'>>

...as well as the delimiter of each of the child <<sheS>> macro arguments.

You can use single quote pairs and double quote pairs to delimit a String literal value.

'This is a String literal value'

"This is also a String literal value"

You can alternate which quote you use if you need to include the other one within the String value.

"It's OK to include single quotes within a double quote delimited String"

'Bob says "you can use double quotes within a single quote delimited String"' 

You can use a backslash \ character if you also need to use the delimiting quotes within the String value.

'Jane says "It\'s OK to use a single quote as long as it\'s escaped with a backslash!"'

"Jane also says \"You can do the same when it's a double quote delimited String too\""

Using the above information try doing the following instead.

<<chat '$name' '$mName' $name "Hello <<sheS 'you' '$mName'>>" $mName 'Hello !'>>


by (2.4k points)
Works like a charm. Thanks to you both.
0 votes
by (44.7k points)

For something like that you're better off creating a macro for the "chat" than using a widget.  That way you can do something like this:

<<chat '$name' '$mName'>>

$name 'Hello <<sheS 'you' '$mName'>> 
$mName 'Hello !'


It will require a bit of JavaScript though.  See the macro API documentation for details and sample code.

by (2.4k points)
Thanks for your answer;

Knowing next to nothing to JavaScript, could you please tell me what exactly "SkipArgs" and "tags" are about, within the possible properties of the macro ?
Will I be able to re-write my widget in JavaScript without JavaScript knowledge ?
by (44.7k points)
I can't answer your second question other than "maybe", so for the first question, the "Definition object" section at the link I gave you explains "SkipArgs" and "tags".
by (2.4k points)
The thing is, I asked my first question because I couldn't understand the explanation given by your link haha.
I guess there's a long way to go for me.