home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Zodiac Super OZ
/
MEDIADEPOT.ISO
/
FILES
/
13
/
N_B_V203.ZIP
/
HEX$.DMO
< prev
next >
Wrap
Text File
|
1996-07-04
|
5KB
|
113 lines
$if 0
┌──────────────────────────╖ PowerBASIC v3.20
┌──┤ DASoft ╟──────────────────────┬──────────────────╖
│ ├──────────────────────────╢ Copyright 1995 │ DATE: 1995-10-01 ╟─╖
│ │ FILE NAME HEX$ .DMO ║ by ╘════════════════─ ║ ║
│ │ ║ Don Schullian, Jr. ║ ║
│ ╘══════════════════════════╝ ║ ║
│ A license is hereby granted to the holder to use this source code in ║ ║
│ any program, commercial or otherwise, without receiving the express ║ ║
│ permission of the copyright holder and without paying any royalties, ║ ║
│ as long as this code is not distributed in any compilable format. ║ ║
│ IE: source code files, PowerBASIC Unit files, and printed listings ║ ║
╘═╤═════════════════════════════════════════════════════════════════════╝ ║
│ .................................... ║
╘═══════════════════════════════════════════════════════════════════════╝
$endif
'.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°
' ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° °
$INCLUDE "DAS-NB01.INC"
SHARED sMask$ : sMask$ = "##,###,###,### or "
COLOR 7, 0
CLS
? "┌────────────────────────
? "│ fHEX$( Value&, Bytes? ) converts a decimal number into a hexadecimal
? "│ expression that has been padded and formatted
? "│ to the length you have requested.
? "│
? "│ fHEXval&( B$ ) converts DASoft's hexadecimal strings or standard
? "│ hexadecimal strings back into decimal numbers.
? "├──────────────────────────────────────────────────────────────────────┘
? "│ fHEX$ creates hexadecimal strings that allow for easy viewing.
? "│ They can only be used, again, as numbers by fHEXval&.
? "│ These routines were used to enhance the printing of hexadecimal
? "│ expressions while programming. It really started out as a
? "│ programming tool but seems to have grown up a little!
? "└────────────────────────────────────────────────────────────────────────┘
LOCATE 16, 1 : PRINT "DASoft:"
LOCATE 20, 1 : PRINT "PowerBASIC:"
LOCATE 16, 50 : PRINT "<HOME> & <END> +- 1"
LOCATE 17, 50 : PRINT "<UP> & <DOWN> +- 100"
LOCATE 18, 50 : PRINT "<PgUp> & <PgDn> +- 1000"
LOCATE 25, 50 : PRINT "PRESS <ESC> TO END";
'┌──────────────────────
B? = 95 '│ assign some values
I% = 56 '│ and create 3 strings
L& = 65536 '│ of 1 byte, 2 bytes &
'│ 4 bytes
DO '│
DisplayB B? '│ display the results
DisplayI I% '│
DisplayL L& '│
WHILE INSTAT : G$ = INKEY$ : WEND '│ clear the keyboard
WHILE NOT INSTAT : WEND '│ wait for a key press
SELECT CASE INKEY$ '│ evaluate the key press
CASE CHR$(27) : EXIT LOOP '│ <ESC> end program
CASE CHR$(000,071) : B? = MIN( 255, B? + 1) '│ <HOME> incr B?
CASE CHR$(000,079) : B? = MAX( 0, B? - 1) '│ <END> decr B?
CASE CHR$(000,072) : I% = MIN( 32767, I% + 100) '│ <UP> incr I%
CASE CHR$(000,080) : I% = MAX(-32767, I% - 100) '│ <DOWN> decr I%
CASE CHR$(000,073) : INCR L&, 1000 '│ <PgUp> incr L&
CASE CHR$(000,081) : DECR L&, 1000 '│ <PgDn> decr L&
END SELECT '│
LOOP '│
'────────────────────────────────────────────────────┼──────────────────────
CLS '│ end of program
END '│
'────────────────────────────────────────────────────┴──────────────────────
SUB DisplayB( BYVAL B? ) LOCAL PUBLIC
LOCAL B$
LOCATE 16, 13
B$ = fHEX$( B?, 1 )
B? = fHEXvalB?( B$ )
PRINT USING sMask$; B?; : PRINT B$
LOCATE 20, 13
PRINT USING sMask$; B?;
PRINT HEX$( B? ); SPACE$(12)
END SUB
SUB DisplayI( BYVAL I% ) LOCAL PUBLIC
LOCAL I$
LOCATE 17, 13
I$ = fHEX$( I%, 2 )
I% = fHEXvalI%( I$ )
PRINT USING sMask$; I%; : PRINT I$
LOCATE 21, 13
PRINT USING sMask$; I%;
PRINT HEX$( I% ); SPACE$(12)
END SUB
SUB DisplayL( BYVAL L& ) LOCAL PUBLIC
LOCAL L$
LOCATE 18, 13
L$ = fHEX$( L&, 4 )
L& = fHEXvalL&( L$ )
PRINT USING sMask$; L&; : PRINT L$
LOCATE 22, 13
PRINT USING sMask$; L&;
PRINT HEX$( L& ); SPACE$(12)
END SUB