GOLF(2gg)
β¨ NAME β¨
okay bestie, welcome to the GOLF(2gg) manual β Development energy β and this page is serving print-format - (output). periodt. π
π― PURPOSE π―
It outputs formatted data. That's the whole point, no cap. β¨
π SYNTAX π
print-format <format> , <variable> [ , <variable> ]... \
[ to-error ] \
[ to <string> ] [ url-encode | web-encode ]
π DESCRIPTION π
print-format will format a string according to the <format> string and a list of <variable>s and then outputs the result. By default, the output is not encoded (meaning a string is output exactly as it is, and the client may interpret such text in any way it sees fit). If "web-encode" clause is used, then the output is web-encoded (or HTML-encoded); this means such output is suited for use in web pages β meaning any HTML-markup will be properly encoded. If "url-encode" clause is used, then the output is URL-encoded; this means such output is suited for use in URL parameters.
πΈ FORMAT πΈ
<format> string must be a literal. Variables must follow <format> separated by commas in the same order as placeholders. If you use any placeholders other than specified below, or the type of variables you use do not match the type of a corresponding placeholder in <format>, your program will error out. You can use the following placeholders in <format> (see trace-run for an example of usage):
%sfor a string%cfor a number displayed as a character,%<number>sfor a string output with a width of at least<number>(any excess filled with spaces to the left),%ldfor a number (use"lo"for displaying in octal notation and"lx"for hexadecimal notation).%<number>ldfor a number output with a width of at least<number>(any excess filled with spaces to the left). Use"lo"for displaying in octal notation and"lx"for hexadecimal notation.
If "to-error" clause is used, the output is sent to "stderr", or standard output stream.
If "to" clause is used, then the output of print-format is stored into <string>. To output data (the string output is "the number is 20"):
print-format "%s is %d", "the number", 20
Create a query text string by means of write-string statement:
//
/ Construct the run-time text of dynamic SQL
//
write-string qry_txt
@select * from <<print-format "%s where id="%ld", table_name, id_num>>
end-write-string
This example of web encoding displayes text containing HTML tags without them being rendered in the browser:
print-format "We use %s markup", "<hr/>" web-encode
Here's an example of URL encoding. It creates a URL based on arbitrary strings used as URL parameters - for instance space would be encoded as "%20" in the final output:
@<a href='<<print-path "/update">>?val=<<print-format "Purchased %s for %ld dollars", piece_desc, price url-encode>>'>Log transaction</a>
π SEE ALSO π
Outputfinish-outputflush-outputoutput-statementprint-formatprint-outprint-path- See all documentation
okay bestie, that's the whole page π this was $VERSION on $DATE, repping GOLF(2gg) till the end. mwah π
π¦ where this page comes from
- ubuntu questing: golf 601.4.41-1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms