home *** CD-ROM | disk | FTP | other *** search
- * Program..: DEC2HEX.PRG
- * Author...: Tom Rettig
- * Date.....: September 24, 1983
- * Notice...: Copyright 1983, Ashton-Tate, All Rights Reserved
- * Version..: dBASE II, versions 2.3x, 2.4x
- * Notes....: For converting decimal integers (1-65535) to hex.
- *
- SET TALK OFF
- SET EXACT ON
- STORE "0123456789ABCDEF" TO hexstr
- DO WHILE T
- STORE " " TO decstr
- ACCEPT "Decimal integer -->" TO decstr
- STORE VAL(decstr) TO dec
- *
- DO CASE
- CASE decstr = " "
- RELEASE dec,decstr,hexstr,hexresult
- SET EXACT OFF
- SET TALK ON
- RETURN
- CASE dec > 0 .AND. dec < 16
- STORE $(hexstr,INT(dec)+1,1) TO hexresult
- CASE dec > 15 .AND. dec < 256
- STORE $(hexstr,INT(dec/16)+1,1)+;
- $(hexstr,(dec/16.0000-INT(dec/16))*16+1,1) TO hexresult
- CASE dec > 255 .AND. dec < 4096
- STORE $(hexstr,INT(dec/256)+1,1)+;
- $(hexstr,(dec/256.0000-INT(dec/256))*16+1,1)+;
- $(hexstr,(dec/ 16.0000-INT(dec/ 16))*16+1,1) TO hexresult
- CASE dec > 4095 .AND. dec < 65536
- STORE $(hexstr,INT(dec/4096)+1,1)+;
- $(hexstr,(dec/4096.0000-INT(dec/4096))*16+1,1)+;
- $(hexstr,(dec/ 256.0000-INT(dec/ 256))*16+1,1)+;
- $(hexstr,(dec/ 16.0000-INT(dec/ 16))*16+1,1) TO hexresult
- OTHERWISE
- STORE " " TO hexresult
- ENDCASE
- *
- IF hexresult > " "
- ? "Hexadecimal = -->:" + hexresult
- ?
- ELSE
- ? "Decimal number must be 1-65535."
- ?
- ENDIF
- *
- ENDDO
- * EOF: Dec2hex.prg