2021.07.31 05:39 AM
Good morning everybody!
How to display a string without the quotes?
Example:
q) show "string"
"string"
q) show "string"
string
2021.07.31 07:58 AM
I managed to do it that way:
1"Hello, world!\n";
1"KDB+ - Q Language\n";
1"/n";
exit 0;
Is there another way to display a string without quotes?
2021.08.04 08:13 AM
negating the handle will append the newline
q)-1"hello, world";
hello, world
q)
q)-1("hello";"world");
hello
world
2021.08.04 06:37 PM
Note on the trailing semi-colon too; this supresses the file handle (1 or -1) being displayed
2021.08.02 01:18 AM - edited 2021.08.04 06:40 PM
Hi @eletrofone,
As you've mentioned, to print strings without the quotes you will need to send the string(s) to the file handle 1 (stdout).
If you to avoid ambiguity with '1' in your code, you could set a variable for re-use e.g.
q)stdout:1;
q)stdout each (("hello";"world"),\:"\n");
hello
world
// use negative to append newline by default
q)stdout:neg 1;
q)stdout ("hello";"world");
hello
world
// note, trailing semi-colon to supress outputting the file handle
Please see here for more info: Handles to files and processes | Basics | q and kdb+ documentation - Kdb+ and q documentation (kx.co...
Cheers,
David
EMEA
Tel: +44 (0)28 3025 2242
AMERICAS
Tel: +1 (212) 447 6700
APAC
Tel: +61 (0)2 9236 5700
KX. All Rights Reserved.
KX and kdb+ are registered trademarks of KX Systems, Inc., a subsidiary of FD Technologies plc.