Doth

From Kx Wiki
Jump to: navigation, search

301 Permanent move

The wiki is moving to a new format and this page is no longer maintained. You can find the new page at code.kx.com/q/ref/doth/.

This page will remain here until the migration is complete. If you prefer the wiki to the new format, please tell the Librarian why.

Contents

.h unreference

The .h namespace contains many functions for converting files into various formats and for web console display. These routines are subject to change, so be careful.

.h.br

The string "<br>".

.h.c0

A web color used by the web console.

.h.c1

A web color used by the web console.

.h.cd

csv from data

converts a table or a list of columns to comma separated values.

Examples:

q).h.cd ([]a:1 2 3;b:`x`y`z)
"a,b"
"1,x"
"2,y"
"3,z"
q).h.cd (`a`b`c;1 2 3;"xyz")
"a,1,x"
"b,2,y"
"c,3,z"

.h.code

TBD

.h.data

TBD

.h.eb

Creates part of an Excel workbook. Used by .h.ed.

.h.ec

Creates part of an Excel workbook. Used by .h.ed.

.h.ed

Excel workbook from Data.

For example:

q).h.ed ([]a:1 2 3;b:`x`y`z)
"<?xml version=\"1.0\"?><?mso-application progid=\"Excel.Sheet\"?>"
"<Workbook xmlns=\"urn:schemas-microsoft-com:office:spreadsheet\" xmlns:o=\"u..
q)

.h.edsn

TBD

.h.es

Creates part of an Excel workbook. Used by .h.ed.

.h.ex

Creates part of an Excel workbook. Used by .h.ed.

.h.fram

Creates an HTML page with two frames. Takes three string arguments: the title; the location of the left frame; the location of the right frame.

.h.ha

Insert HTML hyperlink tag with a anchor, like <a href="ANCHOR">TEXT<a>.

Takes two parameters:

For example:

q) .h.ha[`http://www.example.com;"Example.com Main Page"]
<a href=http://www.example.com>Example.com Main Page</a>
q) .h.ha["http://www.example.com";"Example.com Main Page"]
<a href="http://www.example.com">Example.com Main Page</a>

.h.hb

Same as .h.ha, but adds a "target=v" parameter to the tag.

.h.hc

HTML escape for "<":

q).h.hc "<foo>"
"&lt;foo>"
q)

.h.he

Takes one string argument. Escapes "<" characters, adds a "'" at the front, and then creates an HTTP 400 error (Bad Request) with that content.

.h.hn

Creates an HTTP error from three arguments: a string containing the type of error; a symbol holding the response type (e.g. `csv), and a string containing the content.

.h.hp

Contains the string "html".

.h.hp

Takes one argument, a list of strings. Creates a valid HTTP response displaying these strings, for the web console.

.h.hr

Takes one argument, a strnig, and creates a horizontal rule with one "-" for each character in the string. Used for displaying tables.

.h.ht

HTML documentation generator for http://kx.com/q/d/

  • edit src/mydoc.txt
  • q) .h.ht`mydoc
  • browse mydoc.htm (a/_mydoc.htm is navigation frame, a/mydoc.htm is content frame)

Basic formatting rules:

  • Paragraph text starts at the beginning of the line.
  • Lines beginning with "." are treated as section headings.
  • Lines beginning with "\t" get wrapped in <code><nobr>.
  • Line data beginning with " " get wrapped in <xmp>.
  • If second line of data starts with "-", draw a horizontal rule to format the header.
  • Aligns two column data if 2nd column starts with "\t ".

.h.hta

Insert start tag declaration with set of attributes like: <TAG ATTR1="VAL1" ATTR2="VAL2">. This function does not insert end tag declaration. Please see .h.htac to insert full tag declaration. Takes two parameters: is a TAG name are parameters dictionary where keys are names of attributes and values are values of attributes. For example:

q) .h.hta[`a;(`href`target)!("http://www.example.com";"_blank")]
<a href="http://www.example.com" target="_blank">

.h.htac

Insert tag declaration with set of attributes like: <TAG ATTR1="VAL1" ATTR2="VAL2">BODY</TAG>. This function inserts full tag declaration with start tag, attributes, body and end tag. Takes three parameters: is a TAG name are parameters dictionary where keys are names of attributes and values are values of attributes is a BODY of the tag For example:

q) .h.htac[`a;(`href`target)!("http://www.example.com";"_blank");"Example.com Main Page"]
<a href="http://www.db.com" target="_blank">Example.com Main Page</a>

.h.htc

Inserts simple tag with body without attributes like: <TAG>BODY</TAG> To insert tag with attrbiutes see .h.htac. Takes two parameters: a TAG name of type symbol, and a BODY of the tag of type string.

For example:

q) .h.htc[`tag;"value"]
<tag>value</tag>

.h.html

Inserts simple HTML structure:

<html>
  <head>
    <style>
      a{text-decoration:none}a:link{color:024C7E}a:visited{color:024C7E}a:active{color:958600}body{font:10pt verdana;text-align:justify}
    </style>
   </head>
   <body>
     BODY
   </body>
</html>

Function takes only one argument: BODY of html.

.h.http

Replaces all text started in http:// to html hyperlink.

Takes only one parameter text to be processed.

For example:

q) .h.http "The main page is http://www.example.com"
"The main page is <a href="http://www.example.com">http://www.example.com</a>"

.h.hu

Hex URI (escaping): Replace URI-unsafe characters with %xx.

For example:

q).h.hu "http://www.kx.com"
"http%3a%2f%2fwww.kx.com"

.h.hug

Hex URI (table) Generator: Generate a mapping from characters to %xx escape sequences except for the set of characters passed as the argument (which get mapped to themselves).

.h.hy

Takes two arguments, a symbol and a string. Creates a valid HTTP response, with content type determined by that symbol, and with the string as the content.

.h.iso8601

Takes one numeric argument. Converts it to a timestamp, and returns it as a string in ISO 8601 style.

.h.jx

Renders HTML pagers for tables. Given:

q)a:([] a:til 1000;b:1000?1000;c:1000?1000)

then:

q)first .h.jx[0;`a]
"<a href=\"?[0\">home</a> <a href=\"?[0\">up</a> <a href=\"?[32\">down</a> <a..

A kx.com logo in HTML format.

.h.nbr

Takes one string argument. Returns a "<nobr>" HTML tag with that argument inside.

.h.pre

Takes one argument, a list of strings. Returns a "<pre>" HTML tag displaying those strings, with appropriate newlines.

.h.sa

Some CSS styling used in the web console.

.h.sb

Some CSS styling used in the web console.

.h.sc

List of characters that do not need to be escaped in URIs. See .h.hu.

.h.td

TSV from Data.

For example:

q).h.td ([]a:1 2 3;b:`x`y`z)
"a\tb"
"1\tx"
"2\ty"
"3\tz"

.h.text

Takes one argument, a list of strings. Returns HTML code with each string in its own "

" tag.

.h.tx

A dictionary of file types (`csv, `txt, `xml, `xls) and corresponding conversion functions (.h.cd, .h.td, .h.xd, .h.ed).

.h.ty

A dictionary of response types (e.g. `csv, `bmp, `doc) and corresponding Media Types.

.h.uh

URI Hex (unescaping): Replace %xx sequences with character equivalents.

For example:

q).h.uh "http%3a%2f%2fwww.kx.com"
"http://www.kx.com"

.h.xd

XML from Data.

For example:

q).h.xd ([]a:1 2 3;b:`x`y`z)
"<R>"
"<r><a>1</a><b>x</b></r>"
"<r><a>2</a><b>y</b></r>"
"<r><a>3</a><b>z</b></r>"
"</R>"

.h.xmp

Takes one argument, a list of strings. Returns HTML code displaying the strings, separated by newlines, inside an "xmp" tag.

.h.xs

XML substitutions for entities:

.h.xs "Arthur & Co."
"Arthur &amp; Co."

.h.xt

Signals 'nyi (as of v3.0).

Personal tools
Namespaces
Variants
Actions
Navigation
Print/export
Toolbox