Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

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

Re: mask or wrap single quotes

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

Re: mask or wrap single quotes

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
Valued Contributor II

Re: mask or wrap single quotes

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
Valued Contributor II

Re: mask or wrap single quotes

Hi,

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

regards

Not applicable

Re: mask or wrap single quotes

Call the sub routine like '$(var)'

Re: mask or wrap single quotes

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

Re: mask or wrap single quotes

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

Re: mask or wrap single quotes

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

Employee
Employee

Re: mask or wrap single quotes

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. 

Community Browser