Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
Perhaps by using another character in the variable and the replace function in the sub to add the quote back.
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 " or """" & some statement & """" from other tools are possible.
- Marcus
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
Hi,
maybe using chr(39) would work, have you tried that?,
regards
Call the sub routine like '$(var)'
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
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
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
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.