18.4.0 released Sep 25, 2023
Pf out

Purpose: Outputs a formatted string without encoding.

pf-out [ format ] <format> <expression> [ , <expression> ]... \
    [ bytes-written [ define ] <bytes> ] \
    [ to-error ] \
    [ to [ define ] <string> ]

pf-out formats a string according to the <format> string and a list of variable-type <expression>s (in the same way C's "printf()" does) and then outputs the result without any encoding (meaning a string is output exactly as it is, and the client may interpret such text in any way it sees fit). The result is sent to a client that made the request. If another string is built by using write-string, then the result is output into the buffer that builds a new string.

<format> string must be present. If you'd like to know the number of bytes written out, use the optional "bytes-written" clause, in which case <bytes> holds the number of bytes written; use "define" clause to create it within the statement. There must be at least one <expression> (it means if you want to print out a simple string literal you still have to use "%s" as format).

If <format> is a string constant (eg. "%s %d"), you can omit "format" clause in front of it; however if it is not a string constant (eg. a variable), then you must use "format" clause in front of <format>.

If the optional "to-error" clause is used, the output is sent to "stderr", or standard output stream.

If the optional "to" clause is used, then the output of pf-out is stored into <string>. The <string> can be created with optional "define". <string> is allocated memory.
Examples
To output data (the string output is "the number is 20" and the number of bytes written is in variable "bwritten"):
pf-out bytes-written define bwritten "%s is %d", "the number", 20

The following is writing to client, outputting text for which the browser will interpret tags "<br/>" and "<hr/>" as a line break and a horizontal line and display them as such. It also demonstrates use of "format" clause when <format> is not a constant:
char *fmt = "<hr/> %s <br/>";
pf-out format fmt, "This is a non-encoded output"

Create a query text string by means of write-string statement:
void get_table_data (const char *table_name, num id_num)
{

   //
   // Construct the run-time text of dynamic SQL
   //
   write-string define qry_txt
   @select * from <<pf-out "%s where id="%lld", table_name, id_num>>
   end-write-string
 
}

See also
Output
finish-output  
flush-output  
output-statement  
p-dbl  
pf-out  
pf-url  
pf-web  
p-num  
p-out  
p-path  
p-url  
p-web    
See all
documentation


You are free to copy, redistribute and adapt this web page (even commercially), as long as you give credit and provide a link back to this page (dofollow) - see full license at CC-BY-4.0. Copyright (c) 2019-2023 Dasoftver LLC. Vely and elephant logo are trademarks of Dasoftver LLC. The software and information on this web site are provided "AS IS" and without any warranties or guarantees of any kind.