eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'PrintfScanf':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: PrintfScanf


Inheritance:

   Object
   |
   +--PrintfScanf

Package:
stx:libbasic2
Category:
System-Support
Version:
rev: 1.90 date: 2024/04/24 09:10:46
user: stefan
file: PrintfScanf.st directory: libbasic2
module: stx stc-classLibrary: libbasic2

Description:


 Contributed by Jan Steinman donated to the community in 1989.

 Provided AS-IS - no warranty, use at your own risk.

 Original comment:

     NAME            printf-scanf
     AUTHOR          Jan Steinman <jans@tekgvs.labs.tek.com>
     FUNCTION        printf and scanf for Smalltalk
     ST-VERSIONS     Tek 2.2.2a 4.0
     PREREQUISITES   CharacterComparing
     CONFLICTS       
     DISTRIBUTION    world
     VERSION         1.1
     DATE            Apr 1989?
     SUMMARY 

 The following methods implement printf and scanf functionality.  They
 are intended to be used to ease porting between Smalltalk and C, and
 for facilitating machine-machine communication.  They are not at all
 intended as replacements for Smalltalk's printOn: functionality.

 Jan Steinman - N7JDB
 Tektronix Electronic Systems Laboratory
 Box 500, MS 50-370, Beaverton, OR 97077

 changes:
     slight changes to make it work with higher precision real numbers
     (i.e. asking for the precision instead of hard-coding it)

     no need for the singleton - classes are already singletons ready to use exactly for that.
     (no need to use C++/Java patterns here in Smalltalk)

     Fixed a few corner cases (eg. printing fmin);
     changes to make it work with alternative number classes (eg. LargeFloat)

 Caveat:
     the behavior when the format-width is less than the preferred default precision is suboptimal;
     it leads to problems when trying to format tables into columns...
     For now: always use with width.precision formats to enforce the width.
     The current behavior (generating longer strings like printf does) may change in the future.

format_printf

Printf Format specifier: required: leading '%' optional: '-' (POSIX refers to this as the <<flags>>) optional: positive number or '*' (POSIX: <<width>>) optional: period followed by positive number or * (POSIX: <<precision>>) optional: an h or l to indicate size of data (POSIX: <<length>>) required: character describing output behavior (POSIX: <<conversion specifier>>) Various implementations of printf have added different functionality. ANSI standards up through C99: more flags '+' ' ' '0' '#' more lengths 'L' 'hh' 'll' 'j' 'z' 't' more conversions 'F' 'a' 'A' 'n' The POSIX specification of printf added: positional parameters to identify argument indices more flags ''' (single quote) more conversions 'C' 'S' clarifications regarding corner cases and 'undefined behavior' BSD implementations added: more lengths 'q' more conversions 'D' 'U' 'O' glibc (GNU) added: more lengths 'Z', 'Q' more conversions 'm' Windows C Runtime (CRT) added: more lengths 'I' 'I32' 'I64' 'w' glibc and CRT both added length 'Z'. glibc uses 'Z' for the length size_t. CRT uses Z as a conversion for length-prefixed strings. This implementation takes the former approach, handling 'Z' in the same way as 'z'. BSD and IBM C library both added 'D'. BSD uses D as a conversion, namely as an alias of 'ld'. IBM uses 'D' for the length for _Decimal64, a decimal floating point type, in accordance with ISO/IEC TR 24732. This implementation takes the former approach. ================================================================ This implementation also adds new conversions: 'b' and 'B' for binary (base-2) integer renderings 'y' and 'Y' for true/false and yes/no Boolean conversions 'J' for JSON 'T' and 'V' for JS typeof and valueOf inspection 'S' for store-string 'P' for print-string Prefixes: ' ' fill with spaces '0' fill with zeros '+' print the sign '-' left justified '#' depends: %o, %x, %b: print base prefix %e always show decimal point %e, %E, %f, %g always show decimal point '!' (only after a width spec) mark numbers which exceed the length parameter as '###' (i.e. '%4!d' printf:{12345} => '####' ) Conversions (upper case same as lower case, except for xX): 'a' (not implemented) hex floating point exp form 'b' binary (base 2) 'c' character or (first char of string) 'd' integer 'e' base-10 floating point exp form (scientific) 'f' base-10 floating point decimal form (non-scientific) 'g' 'e' or 'f', whichever looks more appropriate (based on value) 'i' integer (alias for 'd') 'n' (not implemented) stores number of characters written so far into arg 'o' base-8 octal 'p' (not implemented) pointer 's' string 't' type (i.e. class name) 'u' treated like %d (there are no unsigned integers in ST) 'v' (not implemented) store string 'x' base-16 hex 'X' base-16 hex upper case Parameter selection (not implemented): <n>$ take n'th parameter Dynamic width/precision (consumed in order as presented): * take width/parameter from next argument Examples: PrintfScanf printf:'|%d|' arguments:{ 123 } -> '|123|' PrintfScanf printf:'|%5d|' arguments:{ 123 } -> '| 123|' PrintfScanf printf:'|%-5d|' arguments:{ 123 } -> '|123 |' PrintfScanf printf:'|%s|' arguments:{ 'abc' } -> '|abc|' PrintfScanf printf:'|%5s|' arguments:{ 'abc' } -> '| abc|' PrintfScanf printf:'|%*s|' arguments:{ 5 . 'abc' } -> '| abc|' PrintfScanf printf:'|%8f|' arguments:{ 1.234 } -> '| 1.234|' PrintfScanf printf:'|%*f|' arguments:{ 8 . 1.234 } -> '| 1.234|' Negative width will fill at the right: PrintfScanf printf:'|%5s|' arguments:{ 'abc' } -> '| abc|' PrintfScanf printf:'|%-5s|' arguments:{ 'abc' } -> '|abc |' PrintfScanf printf:'|%-*s|' arguments:{ 5 . 'abc' } -> '|abc |' PrintfScanf printf:'|%*s|' arguments:{ -5 . 'abc' } -> '|abc |' PrintfScanf printf:'|%*f|' arguments:{ -8 . 1.234 } -> '|1.234 |' PrintfScanf printf:'|%-8f|' arguments:{ 1.234 } -> '|1.234 |' PrintfScanf printf:'|%-*f|' arguments:{ 8 . 1.234 } -> '|1.234 |' PrintfScanf printf:'|%-*f|' arguments:{ -8 . 1.234 } -> '|1.234 |' PrintfScanf printf:'|%u|' arguments:{ 123 } -> '|123|' PrintfScanf printf:'|%u|' arguments:{ -123 } -> '|-123|' A Zero as fill character: PrintfScanf printf:'|%05s|' arguments:{ 'abc' } -> '|00abc|' PrintfScanf printf:'|%-05s|' arguments:{ 'abc' } -> '|abc00|' PrintfScanf printf:'|%0*f|' arguments:{ -8 . 1.234 } -> '|1.234 |' PrintfScanf printf:'|%-8f|' arguments:{ 1.234 } -> '|1.234 |' PrintfScanf printf:'|%-*f|' arguments:{ 8 . 1.234 } -> '|1.234 |' PrintfScanf printf:'|%-*f|' arguments:{ -8 . 1.234 } -> '|1.234 |' Case of float-format character only affects printing of Nan and infinity: PrintfScanf printf:'%f' argument:1.234 -> '1.234' PrintfScanf printf:'%F' argument:1.234 -> '1.234' PrintfScanf printf:'%f' argument:(Float NaN) -> 'nan' PrintfScanf printf:'%F' argument:(Float NaN) -> 'NAN' PrintfScanf printf:'%f' argument:(Float infinity) -> 'inf' PrintfScanf printf:'%F' argument:(Float infinity) -> 'INF' PrintfScanf printf:'%f' argument:(Float negativeInfinity) -> '-inf' PrintfScanf printf:'%F' argument:(Float negativeInfinity) -> '-INF' PrintfScanf printf:'%+f' argument:(Float infinity) -> '+inf' PrintfScanf printf:'%+F' argument:(Float infinity) -> '+INF' PrintfScanf printf:'%+f' argument:(Float negativeInfinity) -> '-inf' PrintfScanf printf:'%+F' argument:(Float negativeInfinity) -> '-INF' PrintfScanf printf:'% f' argument:(Float infinity) -> ' inf' PrintfScanf printf:'% F' argument:(Float infinity) -> ' INF' PrintfScanf printf:'% f' argument:(Float negativeInfinity) -> '-inf' PrintfScanf printf:'% F' argument:(Float negativeInfinity) -> '-INF' PrintfScanf printf:'%2f' argument:(Float infinity) -> 'inf' PrintfScanf printf:'%2F' argument:(Float infinity) -> 'INF' PrintfScanf printf:'%d' argument:(Infinity positive) -> 'inf' PrintfScanf printf:'%d' argument:(Infinity negative) -> '-inf' PrintfScanf printf:'%2d' argument:(Infinity positive) -> 'INF' PrintfScanf printf:'%2d' argument:(NotANumber NaN) -> 'nan' PrintfScanf printf:'%2o' argument:(NotANumber NaN) -> 'nan' PrintfScanf printf:'%2o' argument:(Infinity positive) -> 'inf' PrintfScanf printf:'%2x' argument:(NotANumber NaN) -> 'nan' PrintfScanf printf:'%2x' argument:(Infinity positive) -> 'inf' PrintfScanf printf:'%2X' argument:(Infinity positive) -> 'inf' Marking too long strings (use too keep tables aligned): PrintfScanf printf:'%2f' argument:1.234 -> '1.234' PrintfScanf printf:'%2!f' argument:1.234 -> '##' PrintfScanf printf:'%2d' argument:99 -> '99' PrintfScanf printf:'%2!d' argument:199 -> '##' PrintfScanf printf:'%2!f' argument:(Float infinity) -> '##' PrintfScanf printf:'%2!f' argument:(Float infinity negated) -> '##' PrintfScanf printf:'%2!f' argument:(Float NaN) -> '##' PrintfScanf printf:'%2!f' argument:(Infinity positive) -> '##' PrintfScanf printf:'%2!f' argument:(Infinity negative) -> '##'

format_scanf

Scanf format specifier: required: leading '%' ================================================================ This implementation also adds new conversions: Conversions (upper case same as lower case): 'b' binary (base 2) 'c' character or (first char of string) 'd' decimal 'e' float 'f' float 'g' float 'i' integer (alias for 'd') 'o' base-8 octal 's' string 'u' integer 'x' base-16 hex 'n' any number 'J' JSON string (upper case 'J' only) Length prefix: 'h' with float formats: reads as ShortFloat 'L' with float formats: reads as LongFloat 'LL' with float formats: reads as QDouble '%d %x' sscanf:'1234 ff00' -> OrderedCollection(1234 65280) '%d %s' sscanf:'1234 ff00' -> OrderedCollection(1234 'ff00') '%d %x %b' sscanf:'1234 ff00 1001' -> OrderedCollection(1234 65280 9) ('%f' sscanf:'1234') first -> 1234.0 (Float i.e. an IEEE double) ('%lf' sscanf:'1234') first -> 1234.0 (Float i.e. an IEEE double) ('%llf' sscanf:'1234') first -> 1234.0 (Float i.e. an IEEE double) ('%hf' sscanf:'1234') first -> 1234.0 (ShortFloat i.e. an IEEE double) ('%Lf' sscanf:'1234') first -> 1234.0 (LongFloat i.e. an IEEE quad) ('%LLf' sscanf:'1234') first -> 1234.0 (QDouble)

Class protocol:

instance creation
o  new
(comment from inherited method)
return an instance of myself without indexed variables

printing
o  printArgFrom: formatStream to: outStream arguments: argStream
Interpret the required number of arguments from <argStream>
according to the formatting information in <formatStream>.
Place the interpretation on <outStream>.
The interpretation is C printf(3) style, as described in the UTek manual page for printf(3).
<formatStream> is assumed to be positioned just past
$%, and a complete control string is assumed available.

Return when the conversion control string is consumed.
Leave <formatStream> pointing past the last character in the conversion control string.

This code assumes that <formatStream> is formatted according to
specification, and error checking is minimal.
Unexpected results will be obtained by illegal control strings, or when
argument types do not match conversion codes, but it probably ;-)
won't dump core, like C does in such cases!!

o  printf: formatString argument: arg
Format and print the receiver with <arg> formatted in C style,
as described in the UTek manual page for printf(3).

Usage example(s):

     self printf:'%e' on:Transcript argument:(1.234 asShortFloat)
     self printf:'%e' on:Transcript argument:(1.234 asFloat)     
     self printf:'%e' on:Transcript argument:(1.234 asLongFloat) 
     self printf:'%e' on:Transcript argument:(1.234 asQDouble)   
     self printf:'%e' on:Transcript argument:(1.234 asInteger)   

     self printf:'%10e' on:Transcript argument:(1.234 asShortFloat)
     self printf:'%10e' on:Transcript argument:(1.234 asFloat)     
     self printf:'%10e' on:Transcript argument:(1.234 asLongFloat) 
     self printf:'%10e' on:Transcript argument:(1.234 asQDouble)   
     self printf:'%10e' on:Transcript argument:(1.234 asInteger)   

     self printf:'%010e' on:Transcript argument:(1.234 asInteger)   
     self printf:'%-10e' on:Transcript argument:(1.234 asInteger)   

     self printf:'%10.9f' on:Transcript argument:(1.2345 asShortFloat)
     self printf:'%10.9f' on:Transcript argument:(1.2345 asFloat)     
     self printf:'%10.9f' on:Transcript argument:(1.2345 asLongFloat) 
     self printf:'%10.9f' on:Transcript argument:(1.2345 asQDouble)   
     self printf:'%10.9f' on:Transcript argument:(1.2345 asInteger)   

o  printf: formatString arguments: args
Format and print the receiver with <args> formatted in C style,
as described in the UTek manual page for printf(3).

Usage example(s):

     self printf:'%e' on:Transcript arguments:{ (1.234 asShortFloat) }
     self printf:'%e' on:Transcript arguments:{ (1.234 asFloat)      }
     self printf:'%e' on:Transcript arguments:{ (1.234 asLongFloat)  }
     self printf:'%e' on:Transcript arguments:{ (1.234 asQDouble)    }
     self printf:'%e' on:Transcript arguments:{ (1.234 asInteger)    }

     self printf:'%10e' on:Transcript arguments:{ (1.234 asShortFloat) }
     self printf:'%10e' on:Transcript arguments:{ (1.234 asFloat)      }
     self printf:'%10e' on:Transcript arguments:{ (1.234 asLongFloat)  }
     self printf:'%10e' on:Transcript arguments:{ (1.234 asQDouble)    }
     self printf:'%10e' on:Transcript arguments:{ (1.234 asInteger)    }

     self printf:'%010e' on:Transcript arguments:{ (1.234 asInteger)    }
     self printf:'%-10e' on:Transcript arguments:{ (1.234 asInteger)    }

     self printf:'%10.9f' on:Transcript arguments:{ (1.2345 asShortFloat) }
     self printf:'%10.9f' on:Transcript arguments:{ (1.2345 asFloat)      }
     self printf:'%10.9f' on:Transcript arguments:{ (1.2345 asLongFloat)  }
     self printf:'%10.9f' on:Transcript arguments:{ (1.2345 asQDouble)    }
     self printf:'%10.9f' on:Transcript arguments:{ (1.2345 asInteger)    }

o  printf: formatString on: outStream argument: arg
Format and print formatString on <outStream> with <arg>
formatted in C style, as described in the UTek manual page for
printf(3).

Usage example(s):

     self printf:'%e' on:Transcript argument:(1.234 asShortFloat). Transcript cr.
     self printf:'%e' on:Transcript argument:(1.234 asFloat)     . Transcript cr.
     self printf:'%e' on:Transcript argument:(1.234 asLongFloat) . Transcript cr.
     self printf:'%e' on:Transcript argument:(1.234 asQDouble)   . Transcript cr.
     self printf:'%e' on:Transcript argument:(1.234 asInteger)   . Transcript cr.

     self printf:'%10e' on:Transcript argument:(1.234 asShortFloat). Transcript cr.
     self printf:'%10e' on:Transcript argument:(1.234 asFloat)     . Transcript cr.
     self printf:'%10e' on:Transcript argument:(1.234 asLongFloat) . Transcript cr.
     self printf:'%10e' on:Transcript argument:(1.234 asQDouble)   . Transcript cr.
     self printf:'%10e' on:Transcript argument:(1.234 asInteger)   . Transcript cr.

     self printf:'%010e' on:Transcript argument:(1.234 asInteger)  . Transcript cr.
     self printf:'%-10e' on:Transcript argument:(1.234 asInteger)  . Transcript cr.

     self printf:'%10.9f' on:Transcript argument:(1.2345 asShortFloat). Transcript cr.
     self printf:'%10.9f' on:Transcript argument:(1.2345 asFloat)     . Transcript cr.
     self printf:'%10.9f' on:Transcript argument:(1.2345 asLongFloat) . Transcript cr.
     self printf:'%10.9f' on:Transcript argument:(1.2345 asQDouble)   . Transcript cr.
     self printf:'%10.9f' on:Transcript argument:(1.2345 asInteger)   . Transcript cr.

o  printf: aFormatString on: outStream arguments: args
Format and print aFormatString on <outStream> with <args>
formatted in C style, as described in the UTek manual page for
printf(3).

Usage example(s):

     self printf:'%e\n' on:Transcript arguments:{ (1.234 asShortFloat) }
     self printf:'%f\n' on:Transcript arguments:{ (1.234 asShortFloat) }
     self printf:'%g\n' on:Transcript arguments:{ (1.234 asShortFloat) }

     self printf:'%e\n' on:Transcript arguments:{ (1.234 asFloat)      }
     self printf:'%f\n' on:Transcript arguments:{ (1.234 asFloat)      }
     self printf:'%g\n' on:Transcript arguments:{ (1.234 asFloat)      }

     self printf:'%e\n' on:Transcript arguments:{ (1.234 asLongFloat)  }
     self printf:'%e\n' on:Transcript arguments:{ (1.234 asQDouble)    }
     self printf:'%e\n' on:Transcript arguments:{ (1.234 asInteger)    }

     self printf:'%10e' on:Transcript arguments:{ (1.234 asShortFloat) }
     self printf:'%10e' on:Transcript arguments:{ (1.234 asFloat)      }
     self printf:'%10e' on:Transcript arguments:{ (1.234 asLongFloat)  }
     self printf:'%10e' on:Transcript arguments:{ (1.234 asQDouble)    }
     self printf:'%10e' on:Transcript arguments:{ (1.234 asInteger)    }

     self printf:'%010e' on:Transcript arguments:{ (1.234 asInteger)    }
     self printf:'%-10e' on:Transcript arguments:{ (1.234 asInteger)    }

     self printf:'%10.9f' on:Transcript arguments:{ (1.2345 asShortFloat) }
     self printf:'%10.9f' on:Transcript arguments:{ (1.2345 asFloat)      }
     self printf:'%10.9f' on:Transcript arguments:{ (1.2345 asLongFloat)  }
     self printf:'%10.9f' on:Transcript arguments:{ (1.2345 asQDouble)    }
     self printf:'%10.9f' on:Transcript arguments:{ (1.2345 asInteger)    }

private helpers
o  absDecimalPrintFloat: aFloat on: aStream digits: digits
Place a string representation of aFloat's abs value on <aStream>,
using <digits> significant digits, using decimal notation.

o  absDecimalPrintFloat: aFloat on: aStream digits: digits precision: precisionOrNil
Place a string representation of aFloat's abs value on <aStream>,
using <digits> significant digits, using decimal notation.

Usage example(s):

     self absDecimalPrintFloat:(Float fmin) on:Transcript digits:10 precision:nil
     self absDecimalPrintFloat:(Float fmax) on:Transcript digits:10 precision:nil

     self absDecimalPrintFloat:(LongFloat fmin) on:Transcript digits:10 precision:nil
     self absDecimalPrintFloat:(LongFloat fmax) on:Transcript digits:10 precision:nil

     self absDecimalPrintFloat:(ShortFloat fmin) on:Transcript digits:10 precision:nil
     self absDecimalPrintFloat:(ShortFloat fmax) on:Transcript digits:10 precision:nil

o  absDecimalPrintFloat: aFloat on: aStream digits: digits precision: precisionOrNil stripTrailingZeros: stripTrailingZeros
Place a string representation of aFloat's abs value on <aStream>,
using <digits> significant digits, using decimal notation.

Usage example(s):

     self absDecimalPrintFloat:(Float fmin) on:Transcript digits:10 precision:nil
     self absDecimalPrintFloat:(Float fmax) on:Transcript digits:10 precision:nil

     self absDecimalPrintFloat:(LongFloat fmin) on:Transcript digits:10 precision:nil
     self absDecimalPrintFloat:(LongFloat fmax) on:Transcript digits:10 precision:nil

     self absDecimalPrintFloat:(ShortFloat fmin) on:Transcript digits:10 precision:nil
     self absDecimalPrintFloat:(ShortFloat fmax) on:Transcript digits:10 precision:nil

o  absPrintFloat: aFloat on: aStream digits: digits
Place a string representation of aFloat's abs value on <aStream>,
using <digits> significant digits.

o  absPrintFloat: aFloat on: aStream digits: digits precision: precision withExponentSign: withExponentSign
Place a string representation of aFloat's abs value on <aStream>,
using <digits> significant digits.
This is invoked for the %g format

o  absPrintFloat: aFloat on: aStream digits: digits withExponentSign: withExponentSign
Place a string representation of aFloat's abs value on <aStream>,
using <digits> significant digits.

o  absScientificPrintFloat: aFloat on: aStream digits: digits
Place a string representation of aFloat's abs value on <aStream>,
using <digits> significant digits, using scientific notation (i.e. #.#e##).

Usage example(s):

     self absScientificPrintFloat:(Float fmin) on:Transcript digits:10
     self absScientificPrintFloat:(Float fmax) on:Transcript digits:10

     self absScientificPrintFloat:(LongFloat fmin) on:Transcript digits:10
     self absScientificPrintFloat:(LongFloat fmax) on:Transcript digits:10

     self absScientificPrintFloat:(ShortFloat fmin) on:Transcript digits:10
     self absScientificPrintFloat:(ShortFloat fmax) on:Transcript digits:10

o  absScientificPrintFloat: aFloat on: aStream digits: digits withExponentSign: withExponentSign
Place a string representation of aFloat's abs value on <aStream>,
using <digits> significant digits, using scientific notation (i.e. #.#e##).
withExponentSign controls if a positive exponent will be printed with a '+' prefix

Usage example(s):

     self absScientificPrintFloat:(Float fmin) on:Transcript digits:10
     self absScientificPrintFloat:(Float fmax) on:Transcript digits:10

     self absScientificPrintFloat:(LongFloat fmin) on:Transcript digits:10
     self absScientificPrintFloat:(LongFloat fmax) on:Transcript digits:10

     self absScientificPrintFloat:(ShortFloat fmin) on:Transcript digits:10
     self absScientificPrintFloat:(ShortFloat fmax) on:Transcript digits:10

o  commonPrintAbsInfiniteOrZero: aFloat on: aStream
'%f' printf:{Float NaN}
'%f' printf:{Float NaN negated}
'%f' printf:{Float infinity}
'%f' printf:{Float negativeInfinity}

'%+f' printf:{Float NaN}
'%+f' printf:{Float NaN negated}
'%+f' printf:{Float infinity}
'%+f' printf:{Float negativeInfinity}

o  formatArgCountFor: aFormatString
Return the number of arguments required/produced,
if the argument is interpreted as a printf/scanf format control string.

o  scanArgFrom: dataStream to: collection format: formatStream
Add to <collection> an object who's representation is found
in <dataStream> interpreted according to the conversion
control string in the Stream <format>. <format> is assumed to
be positioned just past a $%, and a complete control string is
assumed available.

Return when the conversion control string is consumed. Leave
<format> pointing past the last character in the conversion
control string, leave <dataStream> pointing past any width
specified in <format>, or at the first character that doesn't
make sense for the <format>.

scanning
o  scanf: formatString fromStream: dataStream
Return a Collection of objects found in the Character Stream
<dataStream> as interpreted according to the receiver. The
receiver is assumed to be a conversion control string as
specified in the UTek manual page for scanf(3).

o  sscanf: formatString fromString: aString
Return a Collection of objects found in <string> as
interpreted according to the receiver. The receiver is
assumed to be a conversion control string as specified in the
UTek manual page for scanf(3).

Usage example(s):

     self sscanf:'%d %d %d' fromString:'123 45 999'
     '%d %d %d' scanf:'123 45 999'


Instance protocol:

helpers
o  absDecimalPrintFloat: arg1 on: arg2 digits: arg3

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  absPrintFloat: arg1 on: arg2 digits: arg3

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  absScientificPrintFloat: arg1 on: arg2 digits: arg3

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  formatArgCountFor: arg

** This is an obsolete interface - do not use it (it may vanish in future versions) **

printing
o  printArgFrom: arg1 to: arg2 arguments: arg3

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  printf: aString arguments: args
Format and print the receiver with <args> formatted in C style,
as described in the UTek manual page for printf(3).
Returns the formatted printString.

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  printf: aFormatString on: outStream arguments: args
Format and print aFormatString on <outStream> with <args>
formatted in C style, as described in the UTek manual page for
printf(3).

** This is an obsolete interface - do not use it (it may vanish in future versions) **

scanning
o  scanArgFrom: dataStream to: collection format: format
Add to <collection> an object who's representation is found
in <dataStream> interpreted according to the conversion
control string in the Stream <format>. <format> is assumed to
be positioned just past a $%, and a complete control string is
assumed available.

Return when the conversion control string is consumed. Leave
<format> pointing past the last character in the conversion
control string, leave <dataStream> pointing past any width
specified in <format>, or at the first character that doesn't
make sense for the <format>.

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  scanf: formatString fromStream: dataStream
Return a Collection of objects found in the Character Stream
<dataStream> as interpreted according to the receiver. The
receiver is assumed to be a conversion control string as
specified in the UTek manual page for scanf(3).

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  sscanf: formatString fromString: aString
Return a Collection of objects found in <string> as
interpreted according to the receiver. The receiver is
assumed to be a conversion control string as specified in the
UTek manual page for scanf(3).

** This is an obsolete interface - do not use it (it may vanish in future versions) **


Examples:


self printf:'%#x %#X %03o%*.*s' arguments: #(16rABCD 16rEF 5 9 5 'ghijklmn')
        -> '0xabcd 0xEF 005    ghijk'

self printf:'%- 10.4s%.2e' arguments: { 'abcdefghijkl' . Float pi }  
        -> ' abcd      3.14e0'
        
self printf:'%8.3f' arguments: { 200 sqrt negated }
        -> ' -14.142'

self printf:'%8.3f' on:Transcript arguments: { 200 sqrt negated }
self printf:'%10.4f' on:Transcript arguments: { 200 sqrt negated }
self printf:'%20.10f' on:Transcript arguments: { 200 sqrt negated }

self printf:'%20.10f' on:Transcript arguments: { 1.234567890123456789f  }
self printf:'%20.10f' on:Transcript arguments: { 1.234567890123456789q  }

self printf:'%x' arguments: #(16r41)        -> '41' 
self printf:'%#x' arguments: #(16r41)       -> '0x41'
self printf:'%d' arguments: #(16r41)        -> '65'
self printf:'%b' arguments: #(16r41)        -> '1000001'
self printf:'%c' arguments: #(16r41)        -> 'A'
self printf:'%c' arguments: #( $A )         -> 'A'
self printf:'%s' arguments: #( $A )         -> 'A'
self printf:'%s' arguments: #( 'hello' )    -> 'hello'
self printf:'%4s' arguments: #( 'hello' )   -> 'hello'
self printf:'%7s' arguments: #( 'hello' )   -> '  hello'

self sscanf:'%f%2s%s%s%s' fromString: '237.0 this is a test' 
        -> OrderedCollection(237.0 'th' 'is' 'is' 'a')

self sscanf:'%d%f%s' fromString: '25 54.32e-01 monday'
        -> OrderedCollection(25 5.432 'monday')

self sscanf:'%f%*f %8[A-F0-9]%c%d 0x%x%f' fromString: '12.45 1048.73 AE40Z527 0x75BCD15 34' 
        -> OrderedCollection(12.45 'AE40' 'Z' 527 123456789 34.0)

'%#x %#X %03o%*.*s' printf: #(16rABCD 16rEF 5 9 5 'ghijklmn') 
        -> '0xabcd 0xEF 005    ghijk'

'%- 10.4s%.2e' printf: { 'abcdefghijkl' . Float pi }  
        -> ' abcd      3.14e0'

'%8.3f' printf: { 200 sqrt negated }
        -> ' -14.142'

'%c' printf: #(16r41)
        -> 'A'

'%f%2s%s%s%s' sscanf: '237.0 this is a test' 
        -> OrderedCollection(237.0 'th' 'is' 'is' 'a')

'%d%f%s' sscanf: '25 54.32e-01 monday'
        -> OrderedCollection(25 5.432 'monday')

'%f%*f %8[A-F0-9]%c%d 0x%x%f' sscanf: '12.45 1048.73 AE40Z527 0x75BCD15 34'
        -> OrderedCollection(12.45 'AE40' 'Z' 527 123456789 34.0)

'|%d|\n' printf:{ 1234 } on:Transcript    

'|%05d|\n' printf:{ 1234 } on:Transcript    
'|%-5d|\n' printf:{ 1234 } on:Transcript    
'|% 5d|\n' printf:{ 1234 } on:Transcript    
'|%#5d|\n' printf:{ 1234 } on:Transcript    

'|%#8x|\n' printf:{ 1234 } on:Transcript    
'|%#08x|\n' printf:{ 1234 } on:Transcript    
'|%#-8x|\n' printf:{ 1234 } on:Transcript    
'|%#8o|\n' printf:{ 1234 } on:Transcript    
'|%#14b|\n' printf:{ 1234 } on:Transcript    
'|%#014b|\n' printf:{ 1234 } on:Transcript    

'%f\n' printf:{ 1234.0 } on:Transcript        
'%f\n' printf:{ 1234.0 asShortFloat } on:Transcript        
'%f\n' printf:{ 1234.0 asLongFloat } on:Transcript        
'%f\n' printf:{ 1234.0 asQDouble } on:Transcript        

'%p\n' printf:{ 10@20 } on:Transcript        
'%P\n' printf:{ 10@20 } on:Transcript        
'%S\n' printf:{ 10@20 } on:Transcript        


ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Thu, 21 Nov 2024 11:40:50 GMT