UnHex$

From BR Wiki
Jump to navigation Jump to search
UNHEX$(<string>)

The UnHex$ internal function converts A$ to hexadecimal representation.

Comments and Examples

The following example shows the relationship between HEX$ and UNHEX$:

00010 print UNHEX$("+") ! the hexadecimal value which represents the "+" character
00020 print  HEX$("2B") ! the character represented by the hexadecimal value "2B"

Output:

2B
+

UnHex$ can be used to examine the packed decimal representation (PD format) of a number written to an internal or external file.

00010 OPEN #1: "name=billtest,replace,recl=4",INTERNAL,OUTIN,RELATIVE
00020 WRITE #1,USING 30,REC=1:4.56,-4.56
00030 FORM 2*PD 2.2
00040 READ #1,USING 50,REC=1:A$,B$
00050 FORM 2*C 2
00060 REREAD #1,USING 30:A,B
00070 PRINT STR$(A)&" in PD 2.2 format is  - "&UNHEX$(A$)
00080 PRINT STR$(B)&" in PD 2.2 format is  - "&UNHEX$(B$)

The above program will print the following:

4.56 in PD 2.2 format is  - 456F
-4.56 in PD 2.2 format is  - 456D

See the KStat$ function for another example of using UnHex$.

Related Functions

Inverse function is Hex$.