Knowledge Base

Byte formatting function b(Source {, Format})

Specifies byte sized (8-bit, values 0 to 255) data as an argument to a supporting hash function. The first argument specifies where to get the data (the source). The second, optional, argument specifies the actual display format. If the format is not specified, the format defaults to decimal, variable width.

While the obvious use of this is in the Print() hash function, it can also be used in such functions as SetCursor or HBar.

Source specifiers

The following are the allowable source specifiers

FormMeaningExample
=xContents of the X register#HMI Print(b(=x))
=yContents of the Y register#HMI Print(b(=y))
=hContents of the H register#HMI Print(b(=h))
=mContents of the M register#HMI Print(b(=m))
=sContents of the S register#HMI Print(b(=s))
=iContents of the I register#HMI Print(b(=i))
ConstantContents of an EQUated constantFoo EQU 56...#HMI Print(b(Foo))
A number 0 – 255An immediate numeric value#HMI Print(b(165))
*LabelContents of a RAM byte (variable)Temperature defBYTE...#HMI Print(b(*Temperature))
index/jndex modifiers

RAM variable references can also have index/jndex modifiers

FormWhat is sourcedExample code
*+bbWhatever is in RAM (byte) variable bb, with IasJ: applied#HMI Print(b(*+Counter)) ;Force indexing
*-bbWhatever is in RAM (byte) variable bb, with NoJ: applied#HMI Print(b(*-Counter)) ;Inhibit jndexing

NOTE: The modifier (+ or -) must be after the asterisk. jndexing applies only to code running inside a MultiTrack task.

Format specifiers

The format argument specifies how the number is to be displayed. Valid format specifiers are:

FormResulting formatExampleResult (the single quotes are NOT printed)
Blank (default)Decimal, variable width#HMI Print(b(56))'56'
fDecimal in fixed field width (3 characters)#HMI Print(b(56, f))' 56'
vDecimal in variable field width (as many characters positions as are needed.#HMI Print(b(56, v))'56'
2Decimal, in 2 character field, padded with 0. Intended for displaying RTC time.#HMI Print(b(=h, 2))'06'
hHexadecimal in a field of two character positions#HMI Print(b(165, h))#HMI Print(b(10, h))'A5''0A'
cASCII characterLoadX 65
#HMI Print(b(=x,c))
‘A’