SPLat Logo

Byte formatting function b(Source {, Format})

NOTICE: We are updating our website. For product enquiries and orders please contact us directly.
NOTICE: SPLat Controls has moved. We are now at 1/85 Brunel Rd, Seaford, 3198. map

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

=x

Contents of the X register

#HMI Print(b(=x))

=y

Contents of the Y register

#HMI Print(b(=y))

=h

Contents of the H register (RTC hours)

#HMI Print(b(=h))

=m

Contents of the M register (RTC minutes)

#HMI Print(b(=m))

=s

Contents of the S register (RTC seconds)

#HMI Print(b(=s))

=i

Contents of the I register

#HMI Print(b(=i))

Constant

Contents of an EQUated constant

Foo EQU 56

...

#HMI Print(b(Foo))

A number 0 - 255 An immediate numeric value

#HMI Print(b(165))

*Label

Contents 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

*+bb

Whatever is in RAM (byte) variable bb, with IasJ: applied

#HMI Print(b(*+Counter)) ;Force indexing

*-bb

Whatever 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'

f

Decimal in fixed field width (3 characters)

#HMI Print(b(56, f))

' 56'

v

Decimal in variable field width (as many characters positions as are needed.

#HMI Print(b(56, v))

'56'

2

Decimal, in 2 character field, padded with 0. Intended for displaying RTC time.

#HMI Print(b(=h, 2))

'06'

h

Hexadecimal in a field of two character positions

#HMI Print(b(165, h))

#HMI Print(b(10, h))

'A5'

'0A'

c

ASCII character

LoadX 65
#HMI Print(b(=x,c))

'A'