Difference between revisions of "LOGF()"
From Lianjapedia
Yvonne.milne (Talk | contribs) |
|||
(5 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
==Purpose== | ==Purpose== | ||
Function to display a string with 'C' style picture formatting to the current standard error destination | Function to display a string with 'C' style picture formatting to the current standard error destination | ||
− | |||
==Syntax== | ==Syntax== | ||
LOGF(<expC>, <exp1> [,<exp2>...]) | LOGF(<expC>, <exp1> [,<exp2>...]) | ||
− | |||
==See Also== | ==See Also== | ||
[[ETOS()]], [[FPRINTF()]], [[PRINTF()]], [[SPRINTF()]], [[TOSTRING()]] | [[ETOS()]], [[FPRINTF()]], [[PRINTF()]], [[SPRINTF()]], [[TOSTRING()]] | ||
− | |||
==Description== | ==Description== | ||
The LOGF() function displays a string including one or more parameters, <exp1> [,<exp2>...], formatted according to the 'C' style options specified in <expC> to the current standard error destination. Each formatting sequence is applied to the corresponding parameter in the parameter list from left to right. | The LOGF() function displays a string including one or more parameters, <exp1> [,<exp2>...], formatted according to the 'C' style options specified in <expC> to the current standard error destination. Each formatting sequence is applied to the corresponding parameter in the parameter list from left to right. | ||
− | + | {| class="wikitable" width="100%" | |
− | {| class="wikitable" | + | !width="30%"|Formatting option||Description |
− | !Formatting option||Description | + | |
|- | |- | ||
− | |%s||Convert to character string (similar to using [[ETOS()]] or [[TOSTRING()]] | + | |valign="top"|%s||Convert to character string (similar to using [[ETOS()]] or [[TOSTRING()]] |
|- | |- | ||
|%d||For date parameters | |%d||For date parameters | ||
Line 28: | Line 24: | ||
|%t||For datetime parameters | |%t||For datetime parameters | ||
|- | |- | ||
− | |%T||For datetime parameters; character day is also displayed | + | |valign="top"|%T||For datetime parameters; character day is also displayed |
|- | |- | ||
|%l||For logical parameters: True, False | |%l||For logical parameters: True, False | ||
Line 35: | Line 31: | ||
|- | |- | ||
|} | |} | ||
− | |||
Formatting sequences can also contain the following options. These are specified in order, between the '%' and the data type letter. | Formatting sequences can also contain the following options. These are specified in order, between the '%' and the data type letter. | ||
− | + | {| class="wikitable" width="100%" | |
− | {| class="wikitable" | + | !width="30%"|Formatting option||Description |
− | !Formatting option||Description | + | |
|- | |- | ||
|-||Left-justify | |-||Left-justify | ||
Line 47: | Line 41: | ||
|n||Left pad with spaces to width n | |n||Left pad with spaces to width n | ||
|- | |- | ||
− | |n.p||Left pad with spaces to width n and include the decimal point and p decimal places (%f only) | + | |valign="top"|n.p||Left pad with spaces to width n and include the decimal point and p decimal places (%f only) |
|- | |- | ||
|} | |} | ||
− | |||
==Example== | ==Example== | ||
Line 83: | Line 76: | ||
logf('Logicals can also be %L or %L\n',.T.,.F.) | logf('Logicals can also be %L or %L\n',.T.,.F.) | ||
</code> | </code> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
''error.log'' | ''error.log'' | ||
Line 109: | Line 97: | ||
</pre> | </pre> | ||
− | |||
− | |||
− | |||
[[Category:Documentation]] | [[Category:Documentation]] | ||
[[Category:Functions]] | [[Category:Functions]] | ||
− | [[Category: | + | [[Category:Formatting Functions]] |
− | + | ||
[[Category:Lianja VFP Extensions]] | [[Category:Lianja VFP Extensions]] | ||
[[Category:VFP Function Extensions]] | [[Category:VFP Function Extensions]] |
Latest revision as of 13:45, 19 May 2014
Contents
Purpose
Function to display a string with 'C' style picture formatting to the current standard error destination
Syntax
LOGF(<expC>, <exp1> [,<exp2>...])
See Also
ETOS(), FPRINTF(), PRINTF(), SPRINTF(), TOSTRING()
Description
The LOGF() function displays a string including one or more parameters, <exp1> [,<exp2>...], formatted according to the 'C' style options specified in <expC> to the current standard error destination. Each formatting sequence is applied to the corresponding parameter in the parameter list from left to right.
Formatting option | Description |
---|---|
%s | Convert to character string (similar to using ETOS() or TOSTRING() |
%d | For date parameters |
%f | For floating point numeric parameters |
%y | For currency parameters |
%t | For datetime parameters |
%T | For datetime parameters; character day is also displayed |
%l | For logical parameters: True, False |
%L | For logical parameters: Yes, No |
Formatting sequences can also contain the following options. These are specified in order, between the '%' and the data type letter.
Formatting option | Description |
---|---|
- | Left-justify |
n | Left pad with spaces to width n |
n.p | Left pad with spaces to width n and include the decimal point and p decimal places (%f only) |
Example
doc_logf.prg
// When %s is specified, the corresponding argument is converted to // character format (similar to specifying etos()). // Widths correspond to the default values, e.g. numerics are 10 logf('It is %s, %s to be more precise\n',year(date()),datetime()) logf('The value of pi is %s\n',pi()) logf('They cost %s per %s\n',$99,100) logf('Logicals can be %s or %s\n',.T.,.F.) // Formatting sequences can contain a width, which will left pad with spaces logf('Right-justify and pad left: %10s this\n','Like') // Left justify by placing a '-' directly following the '%' character logf('Left-justify and pad right: %-10s this\n','Like') // %d is for numerics logf('It is %d\n',year(date())) // %t and %T are for formating datetime data types. logf('It is %d, %t to be more precise\n',year(date()),datetime()) logf('It is %d, %T to be even more precise\n',year(date()),datetime()) // %f is for floating point numerics logf('The value of pi is %f\n',pi()) // Decimal places can also be specified for floating point numerics (%f) logf('The value of pi to two decimal places is %4.2f\n',pi()) // %y is for formatting currency data types logf('They cost %y per %d\n',$99,100) logf('They cost %y per %d\n',$99,1000) logf('They cost %y per %d\n',$99,10000) //%l and %L are for formatting logical datatypes. logf('Logicals can be %l or %l\n',.T.,.F.) logf('Logicals can also be %L or %L\n',.T.,.F.)
error.log
It is 2009, 11/11/2009 11:41:51 AM to be more precise The value of pi is 3.1415926 They cost $99.0000 per 100 Logicals can be True or False Right-justify and pad left: Like this Left-justify and pad right: Like this It is 2009 It is 2009, 11/11/2009 11:41:51 AM to be more precise It is 2009, Wednesday November 11 2009 11:41:51 to be even more precise The value of pi is 3.141593 The value of pi to two decimal places is 3.14 They cost $99.0000 per 100 They cost $99.0000 per 1000 They cost $99.0000 per 10000 Logicals can be True or False Logicals can also be Yes or No