cancel
Showing results for 
Search instead for 
Did you mean: 

Show or 0N!

eletrofone
New Contributor

Good morning everybody!

How to display a string without the quotes?

Example:

q) show "string"

"string"

 

q) show "string"

string

4 REPLIES 4

eletrofone
New Contributor

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?

negating the handle will append the newline

q)-1"hello, world";
hello, world
q)
q)-1("hello";"world");
hello
world

dcrossey
New Contributor III
New Contributor III

Note on the trailing semi-colon too; this supresses the file handle (1 or -1) being displayed

dcrossey
New Contributor III
New Contributor III

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