dmaz.SFormat: | Functions | Modinfo | Source |
PrintSF | Print a string by combining str and values according to specified formats in str. |
SFormat | Parse string for specified formats and combine it with one or more values. |
Function PrintSF( str:String, values:String[], clip:Int=CLIPERROR ) | |
Description | Print a string by combining str and values according to specified formats in str. |
Information | See SFormat. |
Example | Import dmaz.SFormat Print PrintSF "blah @|||||||||| blah",["cen"] PrintSF "blah @|||||||||| blah",["this is too big to center"],True PrintSF "blah @|||||||||| blah",["this is too big to center"],False PrintSF "blah @|||||||||| blah",["this is too big to center"],CLIPERROR Print PrintSF "blah @<<<<<<<<<< blah",["this is too big to center"],True PrintSF "blah @>>>>>>>>>> blah",["this is too big to center"],True Print Local x:Int = 10 Local y:Int = 56 Local z:Int = 9 PrintSF "x:@ y:@ z:@",[String(x),String(y),String(z)] Print PrintSF "x:@<<<< y:@<<<< z:@<<<<",[String(x),String(y),String(z)] PrintSF "x:@>>>> y:@>>>> z:@>>>>",[String(x),String(y),String(z)] PrintSF "x:@0000 y:@0000 z:@0000",[String(x),String(y),String(z)] Print PrintSF "num: @>>>>>.>>",["8373.892"] PrintSF "num: @>>>>>.>>",["8373.8"] PrintSF "num: @>>>>>.00",["8373.8"] PrintSF "num: @>>>>0.00",[".89"] sformatPrecisionChar = "," PrintSF "num: @>>>>0.00",[""] |
Function SFormat:String( str:String, values:String[], clip:Int=CLIPERROR ) | |
Returns | Returns a string produced according to the supplied string. |
Description | Parse string for specified formats and combine it with one or more values. |
Information | SFormat parses str for the following directives. It then interprets those directives to format a value which
is then inserted into the return string. values is an array of strings that will be processed
one by one with format. clip determines the output of a specific format if the value is
too large to fit within that format.
str is composed of normal text, copied directly to the result and zero or more formats each of which coincide with a value from values. Null values are ok and will still result in the specified format. A format consists of "@" followed by any of >,<,|,.,0. For example: "@>>>>>" will result in a right justified text field 6 (@ is included) characters wide. "@>>>0.00" will result in a right justified field with 2 decimals of precision
clip can be one of the 3 options... |
Version | 1.0 |
---|---|
Author | David Maziarka |
License | Public Domain |
History | 1.00 Release |