Format (Kernel)¶
-
Format
(destString formatString)¶
-
Format
(destString resourceNumber textId) Formats the fmtString with the given parameters and stores it in destString. It then returns a pointer to the destString.
Parameters: - destString (string) – The buffer to which the string will be written.
- formatString (string) – The formatting string.
- resourceNumber (number) – A text resource number.
- textId (number) – An index in the text resource to use for the formatting string.
There are a number of different formatting options available:
; The following are for numbers: (Format aString "Number: %d" 5) ; Would print "Number: 5" (Format aString "Number: %03d" 5) ; Would print "Number: 005" (Format aString "Number: %3d" 5) ; Would print "Number: 5" (Format aString "Number: %-3d" 5) ; Would print "Number: 5 " ; The following are for unsigned numbers: (Format aString "Number: %u" 5) ; Would print "Number: 5" (Format aString "Number: %03u" 5) ; Would print "Number: 005" (Format aString "Number: %3u" 5) ; Would print "Number: 5" (Format aString "Number: %-3u" 5) ; Would print "Number: 5 " ; The following are for hex: (Format aString "Number: %x" $A5) ; Would print "Number: A5" (Format aString "Number: %03x" $A5) ; Would print "Number: 0A5" (Format aString "Number: %3x" $A5) ; Would print "Number: A5" (Format aString "Number: %-3x" $A5) ; Would print "Number: A5 " ; The following are for strings: (Format aString "String: %s" "Hello") ; Would print "String: hello" (Format aString "String: %10s" "Hello") ; Would print "String: Hello" (Format aString "String: %-10s" "Hello") ; Would print "String: Hello "