home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Du Jour
/
SoftwareDuJour.iso
/
BUSINESS
/
DBASE
/
DBAPG.ARC
/
HEX2POKE.PRG
< prev
next >
Wrap
Text File
|
1984-08-12
|
3KB
|
101 lines
* Program.: HEX2POKE.PRG
* Author..: Luis A. Castro
* Date....: 01/17/84
* Notice..: Copyright 1984, Ashton-Tate, All Rights Reserved
* Version.: dBASE II, version 2.4x
* Notes...: Creates a dBASE II POKE sequence from a HEX file.
* Local...: hexvalues, Mhexlen, Mhexaddr, filename,
* address, linelen, decimals, item
*
SET TALK OFF
SET RAW ON
STORE "123456789ABCDEF" TO hexvalues
* ---Macros to convert hex values to decimal values.
STORE [@($(Hlength,1,1),hexvalues)*16 +;
@($(Hlength,2,1),hexvalues)] TO Mhexlen
STORE [@($(Haddress,1,1),hexvalues)*4096+;
@($(Haddress,2,1),hexvalues)*256+;
@($(Haddress,3,1),hexvalues)*16+;
@($(Haddress,4,1),hexvalues)] TO Mhexaddr
*
ERASE
@ 2, 0 SAY "H E X - T O - P O K E C O N V E R T E R"
@ 2,72 SAY DATE()
@ 3, 0 SAY "========================================"
@ 3,40 SAY "========================================"
ACCEPT "Enter hex file....." TO filename
STORE !( TRIM(filename) ) + "." TO filename
STORE $( filename, 1, @(".",filename) - 1 ) TO filename
DO CASE
CASE filename = " "
SET TALK ON
SET RAW OFF
RETURN
CASE .NOT. FILE(filename+".HEX")
? "FILE DOES NOT EXIST"
SET TALK ON
SET RAW OFF
RETURN
ENDCASE
?
? "Copying structure to HEX2POKE.$$$...."
USE Hex2poke
COPY STRUCTURE TO Hex2poke.$$$
USE Hex2poke.$$$
? "Appending from &filename..HEX... "
APPEND FROM &filename..HEX SDF
GO TOP
*
* ---Generate the POKE sequence.
ERASE
SET ALTERNATE TO &filename..LIB
SET ALTERNATE ON
? [* Subroutine.: ]+filename+[.LIB]
? [* Author.....: Your Name]
? [* Created on.: ]+DATE()
? [*]
STORE &Mhexaddr TO address
? [SET CALL TO ]+STR(address,5)
? [* -----------0---1---2---3---4---5---6---7---8---9]
DO WHILE .NOT. EOF
STORE &Mhexlen TO linelen
STORE &Mhexaddr TO address
IF linelen <> 0
STORE " " TO decimals
STORE "11" TO item
DO WHILE VAL(item)-10 <= linelen
STORE decimals+","+STR(@($(H&item,1,1),hexvalues)*16;
+ @($(H&item,2,1),hexvalues),3) TO decimals
STORE STR(VAL(item)+1,2) TO item
ENDDO
DO CASE
CASE LEN(decimals)-2 <= 40
? [POKE ] + STR(address,5) + [,] + $(decimals,3)
CASE LEN(decimals)-2 <= 80
? [POKE ]+STR(address,5)+[,] + $(decimals,3,40)+[;]
? [ ]+$(decimals,43)
OTHERWISE
* ---LEN(decimals)-2 > 80
? [POKE ]+STR(address,5)+[,] + $(decimals,3,40)+[;]
? [ ]+$(decimals,43,40)+[;]
? [ ]+$(decimals,83)
ENDCASE
ENDIF
IF ( # - 4*INT(#/4) ) = 0
? [* -----------0---1---2---3---4---5---6---7---8---9]
ENDIF
SKIP
ENDDO
? [*]
? [RETURN]
? [* EOF: ] + filename + [.LIB]
?
SET ALTERNATE OFF
SET ALTERNATE TO
CLEAR
DELETE FILE Hex2poke.$$$
SET RAW OFF
SET TALK ON
RETURN
* EOF: HEX2POKE.PRG