Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
marcus_sommer

mask or wrap single quotes

Hello,

are there possibilities to mask single quotes or wrap it within other quotes?

By variables I could use: set var = "categorie = 'abc'"; and within the load a call like if($(var), 1,0) as XYZ but if I call a sub-routine with such a parameter: call subXYZ(var) it didn't work.

All variants of masking or wrapping I have tried are failed like wrapping with 2/3/4 single/double quotes or brackets or grave accents ...

Of course I could build a concat string and use chr(39) instead of single-quotes or could use a dummy-char which I later replace but this are unwanted workarounds.

Any ideas? Many thanks!

- Marcus

10 Replies
Gysbert_Wassenaar

Perhaps by using another character in the variable and the replace function in the sub to add the quote back.


talk is cheap, supply exceeds demand
marcus_sommer
Author

Thanks Gysbert, that is actually my workaround but I would like a shorter and more elegant solutions. I could imagine that in qv some masking/wrapping methods like "\\" or &quot or """" & some statement & """" from other tools are possible.

- Marcus

flipside
Partner - Specialist II
Partner - Specialist II

Can you not do what you need using let instead of set?

sub subXYZ(s)
let x = msgbox(s);
table:
load '$(s)' as txt autogenerate 1;
end sub;

let var = '"categorie = ''abc''"';

call subXYZ(var);

Or have I got your requirements wrong?

flipside

jaimeaguilar
Partner - Specialist II
Partner - Specialist II

Hi,

maybe using chr(39) would work, have you tried that?,

regards

Not applicable

Call the sub routine like '$(var)'

marcus_sommer
Author

It's already nearby - but in my real case it didn't worked. I have there a complex field-list with some renames, functions and variables included and it won't be regognized as field-list.

- Marcus

marcus_sommer
Author

That would work but then I need to build this variable like: var = chr(39) & 'some' & chr(39) & 'any' ... this is more effort then the workaround with replace.

- Marcus

marcus_sommer
Author

It makes no differences in this case between var or $(var) or '$(var)' as well as the definition from the variable is per SET or LET.

- Marcus

JonnyPoole
Employee
Employee

I checked with a colleague whose been doing this awhile too.  Don't think it has a standard escape syntax, although in some cases (Set Analysis , Field names in the load script) they are basically ways to have it ignore the single quote. But every usage scenario (variables ,  expressions etc...) is different and i just pick the best trick for the scenario.