KX Community

Find answers, ask questions, and connect with our KX Community around the world.

Home Forums kdb+ Show or 0N!

  • Show or 0N!

    Posted by eletrofone on July 31, 2021 at 12:00 am

    Good morning everybody!

    How to display a string without the quotes?

    Example:

    q) show “string”

    “string”

     

    q) show “string”

    string

    eletrofone replied 1 month, 2 weeks ago 3 Members · 4 Replies
  • 4 Replies
  • eletrofone

    Member
    July 31, 2021 at 12:00 am

    I managed to do it that way:

    1″Hello, world!n”;
    1″KDB+ – Q Languagen”;
    1″/n”;
    exit 0;

    Is there another way to display a string without quotes?

  • dcrossey

    Member
    August 2, 2021 at 12:00 am

    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.com)

    Cheers,

    David

  • jason_fealy

    Member
    August 4, 2021 at 12:00 am

    negating the handle will append the newline

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

    Member
    August 5, 2021 at 12:00 am

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

Log in to reply.