Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
this is very much a two-sided blade: In my book "QlikView 11 for developers", it says that this should always be used, with the exception of text-variables.
I have, however, already had trouble with this on several occasions because
- inside that $(), the syntax_check is deactivated, so there is no way of quickly checking that the variables used actually exist;
- on several occasions, no idea why, the formula just didn't work using this, so I took it off and it worked fine.
Could anybody explain this to me? The book does not really explain what this $() does, does it? I assume that understanding just what it does would go a long way towards understanding when to use it and when not to.
Thanks a lot!
Best regards,
DataNibbler
If your variable contains an expression then dollar expansion is necessary to evaluate the expression so it returns a value. Otherwise it will return the expression as a string. If your variable contains a numeric value then you don't need to expand it, but doing so will simply return the numeric value. If your variable contains a string value then dollar expansion will return a null.
. If your variable contains a string value then dollar expansion will return a null.
Not sure I if understand what you are saying here. If my variable contains a string, the dollar sign expansion replace with this string, in all of my settings. You may need to handle the text replacement in the expression containing the dollar sign expansion correctly, of course, e.g. by quoting.
The fundamental thing about dollar sign expansion is stated at the very beginning of the HELP section:
Dollar-sign expansions are definitions of text replacements used in the script or in expressions. This process is known as expansion - even if the new text is shorter. The replacement is made just before the script statement or the expression is evaluated. Technically it is a macro expansion.
So you need to consider that the content of your variable may be handled differently, when replaced before the actual expression parsing and evaluation is done or as part of that (e.g. when using QV functions within the variable text).
For datanibbler's problem with the syntax checker, one may input first the pure variable name only, get it checked, than add the $( ) around (but I agree that it would be better to have the syntax checker revised, not only for that issue).
Hi,
okay - so it is necessary, albeit problematic in some aspects - yes, usually I do enter the "pure" variable first to check it and then add the $() around it.
Thanks a lot!
Best regards,
DataNibbler
Not sure I if understand what you are saying here. If my variable contains a string, the dollar sign expansion replace with this string, in all of my settings.
You're correct. It will return.. well, let's call it a naked string. Unless you surround that in quotes yourself it will be evaluated as a null. If a variable vTest has the value abc then len($(vTest)) will return 0. And =$(vTest) used as expression in a text box will show a -, i.e. a null. But =vTest will show abc. As will ='$(vTest)'.
And completely agreed on an overhaul of the syntax checker.