Reviewed and revised April 2024
xcall MIAMEX, MX_OCVT, number, size, flags {,strbuf}
MX_OCVT (MIAMEX 9) outputs a number in either hex or octal format.
Parameters
number (Unsigned Int) [in]
Number to display.
size (Unsigned Int) [in]
Width (number of digits) for the formatted display. If zero, the width will be set automatically to just enough to fit. Otherwise the display is padded leading zeroes or spaces to the specified size. Maximum size is 64 digits.
flags (Bitmap, 8 bits) [in]
Zero or more options from the following table.
Symbol |
Value |
Description |
|---|---|---|
OT_ZER |
&h0001 |
Leading zero blanking |
OT_TRM |
&h0002 |
Output to terminal |
OT_MEM |
&h0004 |
Output to memory |
OT_LSP |
&h0010 |
Output leading space |
OT_TSP |
&h0020 |
Output trailing space |
OT_OCT |
&h0040 |
Force output in octal |
OT_HEX |
&h0080 |
Force output in hex |
Definition file: ashell.def |
||
strbuf (String) [out]
String variable to receive the formatted number if OT_MEM flag set. Otherwise this parameter can be omitted.
Comments
If neither OT_OCT nor OT_HEX set, it will use the current default radix. See MX_GETHEX, MX_SETHEX.
The confusingly named OT_ZER bit causes leading zeroes to be converted to spaces; see size and History. The OT_TRM bit should always be specified, and is included for compatibility reasons. The OT_LSP and OT_TSP bits output an additional leading space and trailing space respectively.
The OT_MEM bit indicates that the output is to be stored in memory (and not output directly to the terminal). If this bit is specified, then the fifth parameter (String) must be present, which is a string or unformatted variable into which the formatted numerical output is returned.
See the wrapper functions Fn'Dec2Hex$(decval,flags,width) and Fn'Hex2Dec(hex$) in the SOSLIB:[907,10].
History
2025 August, A-Shell 7.0.1775: Maximum supported size (width) increased from 8 to 64.
2016 June, A-Shell 6.3.1516: MX_OCVT now supports 48 bit values, up from 32. This is equivalent to 12 hex characters or 16 octal characters. Note that the standard Fn'Dec2Hex$() in SOSLIB[907,10] function has been updated accordingly.