home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
High Voltage Shareware
/
high1.zip
/
high1
/
DIR3
/
LIBMAN.ZIP
/
LIBMAN.CLA
next >
Wrap
Text File
|
1994-01-25
|
14KB
|
398 lines
!▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
!█ █
!█ LIBMAN.CLA █
!█ List and extract oject modules from TopSpeed library file █
!█ █
!█ Revision : 1 █
!█ █
!█ Copyright : Bobcat Systems (c) 1994 █
!█ Author : Robert J. Pupazzoni, Bobcat Systems █
!█ █
!█ Compiler : Clarion Professional Developer v.2.1, Batch 2105 █
!█ █
!█ REVISION HISTORY █
!█ 1 Created █
!█ █
!▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
LIBMAN PROGRAM
INCLUDE('STD_KEYS.CLA')
INCLUDE('CTL_KEYS.CLA')
MAP
PROC(BldModTbl)
PROC(ShowModTbl)
PROC(ExtractMod)
FUNC(Confirm),LONG
PROC(ChkErr)
.
sgLibFName STRING(64) ! LIB file name
sgObjFName STRING(64) ! OBJ file name
oLibFile DOS,PRE(OLF),NAME(sgLibFName) ! LIB file
Record RECORD !
STRING(255) !
. . !
oObjFile DOS,PRE(OOB),NAME(sgObjFName) ! OBJ file
Record RECORD !
STRING(255) !
. . !
gTHEADR GROUP,PRE(THD),OVER(OLF:Record) ! THEADR Module record:
ibRecType BYTE ! Record Type
isRecLen SHORT ! Record Length
ibNameLen BYTE ! Module Name length
sName STRING(12) ! Module Name
. !
tModules TABLE,PRE(TMO) ! Modules Table:
ilStart LONG ! Starting file offset
ilSize LONG ! Module size
sName STRING(255) ! Module name
. !
wCover SCREEN HUE(7,0,0)
ROW(1,1) PAINT(1,80),HUE(14,4)
ROW(25,1) PAINT(1,80),HUE(0,7)
ROW(6,2) PAINT(5,78),HUE(0,3)
ROW(2,1) REPEAT(4);STRING('▒{80}') .
ROW(6,1) REPEAT(5);STRING('▒<0{78}>▒') .
ROW(11,1) REPEAT(14);STRING('▒{80}') .
ROW(6,2) STRING('┌─{76}┐')
ROW(7,2) REPEAT(3);STRING('│<0{76}>│') .
ROW(10,2) STRING('└─{76}┘')
ROW(1,23) STRING('LIBMAN - TopSpeed Library Manager 0.1')
ROW(25,3) STRING('Written by Robert Pupazzoni, Bobcat Systems' |
& ' {15}CIS ID:[70441,204]')
ROW(8,5) STRING('Enter library (.LIB) file name:')
COL(37) ENTRY(@S40),USE(sgLibFName),SEL(14,4),REQ
.
CODE
OPEN(wCover) !
LOOP !
ALERT !
ALERT(Esc_Key) !
ACCEPT !
IF KEYCODE() = Esc_Key THEN BREAK. !
OPEN(oLibFile) !
IF ERRORCODE() THEN BEEP; CYCLE. !
BldModTbl() !
ShowModTbl() !
CLOSE(oLibFile) !
. !
RETURN !
!═════════════════════════════════════════════════════════════════════════
! Build module table
!═════════════════════════════════════════════════════════════════════════
BldModTbl PROCEDURE
! Screens:
wScreen SCREEN WINDOW(7,43),PRE(SCR),HUE(0,3)
ROW(1,1) STRING('┌─{41}┐')
ROW(2,1) REPEAT(5);STRING('│<0{41}>│') .
ROW(7,1) STRING('└─{41}┘')
ROW(3,4) STRING('Scanning library file... please wait.')
ROW(5,17) STRING('(')
COL(21) STRING('% done)')
ssPctDone COL(18) STRING(@N3),HUE(15,3)
.
! Locals:
ilFileSize LONG ! File size
ilOffset LONG ! File offset
CODE
OPEN(wScreen) ! Open screen
ilOffset = 1 ! Set starting offset
ilFileSize = BYTES(oLibFile) ! Get file size
LOOP WHILE ilOffset <= ilFileSize ! Loop while not eof
GET(oLibFile, ilOffset, 255) ! Get record
IF THD:ibRecType = 80H ! If it's a module header
DO UpdModSize ! Update previous mod size
DO AddNewMod ! Add module to table
. ! Endif
ilOffset += (3 + THD:isRecLen) ! Move file pointer
SCR:ssPctDone = 100 * (ilOffset / ilFileSize)! Update % done
. ! End loop
DO UpdModSize ! Update final mod size
SORT(tModules, TMO:sName) ! Sort by module name
CLOSE(wScreen) ! Close screen
RETURN !
!─────────────────────────────────────────────────────────────────────────
AddNewMod ROUTINE ! Add new object module to table
!─────────────────────────────────────────────────────────────────────────
CLEAR(tModules) ! Clear table record
TMO:ilStart = ilOffset ! Set mod starting offset
TMO:ilSize = 0 ! We don't know this yet...
TMO:sName = SUB(THD:sName, 1, THD:ibNameLen) ! Set mod name
ADD(tModules) ! Add to table
!─────────────────────────────────────────────────────────────────────────
UpdModSize ROUTINE ! Update module size
!─────────────────────────────────────────────────────────────────────────
GET(tModules, RECORDS(tModules)) ! Get previous mod record
IF NOT ERRORCODE() ! If found
TMO:ilSize = (ilOffset - TMO:ilStart) - 1 ! Now we know the size
PUT(tModules) ! Update it
. ! Endif
!═════════════════════════════════════════════════════════════════════════
! Show module table
!═════════════════════════════════════════════════════════════════════════
ShowModTbl PROCEDURE
! Screens:
wScreen SCREEN WINDOW(24,80),AT(1,1),PRE(SCR),HUE(0,7)
ROW(4,3) PAINT(19,74),HUE(11,1)
ROW(3,77) PAINT(1,1),HUE(0,3)
ROW(1,1) STRING('┌─{24}<0{29}>─{25}┐')
ROW(2,1) STRING('│<0{78}>│')
ROW(3,1) STRING('│<0{75}>▄<0,0>│')
ROW(4,1) REPEAT(19);STRING('│<0{75}>█<0,0>│') .
ROW(23,1) STRING('│<0,0>▀{74}<0,0>│')
ROW(24,1) STRING('└─{78}┘')
ROW(1,27) STRING('O B J E C T M O D U L E S')
ROW(3,6) STRING('Module Name {7}Offset Size')
REPEAT(17),INDEX(ibRepNdx)
ROW(5,5) POINT(1,70),USE(?Point),SEL(14,4),REQ
ssName COL(6) STRING(15)
ssStart COL(23) STRING(@N_7)
ssSize COL(32) STRING(@N_7)
.
ssULArrow COL(4) STRING(1),HUE(14,1)
ssLLArrow ROW(21,4) STRING(1),HUE(14,1)
ssLRArrow COL(75) STRING(1),HUE(14,1)
ssURArrow ROW(5,75) STRING(1),HUE(14,1)
.
wKeyLine SCREEN WINDOW(1,80),AT(25,1),HUE(0,7)
ROW(1,18) STRING('<<')
COL(19) STRING('Enter'),HUE(4,7)
COL(24) STRING('> Extract Module {14}<<')
COL(55) STRING('Esc'),HUE(4,7)
COL(58) STRING('> Exit')
.
! Equates:
eScrlRows EQUATE(17) ! Rows in scroll area
eUpArrow EQUATE('') ! Up arrow symbol
eDnArrow EQUATE('') ! Down arrow symbol
! Locals:
ilTblNdx LONG ! Table index
ilTopRow LONG ! Top row offset
ibRepNdx BYTE ! Repeat index
ibSavRepNdx BYTE ! Saved repeat index
CODE
OPEN(wKeyLine) ! Open screens
OPEN(wScreen) !
DO FirstPage ! Display first page
LOOP ! Loop
ALERT !
ALERT(Esc_Key) !
ALERT(Up_Key) !
ALERT(Down_Key) !
ACCEPT ! Get keystroke
CASE KEYCODE() ! Process keystroke
OF Esc_Key; BREAK !
OF Enter_Key; DO GetRecord !
ExtractMod() !
OF Up_Key; DO MoveUp !
OF Down_Key; DO MoveDown !
OF PgUp_Key; DO PrevPage !
OF PgDn_Key; DO NextPage !
OF Ctrl_PgUp; DO FirstPage !
OF Ctrl_PgDn; DO LastPage !
. . ! End loop
CLOSE(wScreen) ! Close screens
CLOSE(wKeyLine) !
DO Quit ! Clean-up and exit
!─────────────────────────────────────────────────────────────────────────
Quit ROUTINE ! Clean up and exit
!─────────────────────────────────────────────────────────────────────────
RETURN ! Return to caller
!─────────────────────────────────────────────────────────────────────────
FirstPage ROUTINE ! Display first page
!─────────────────────────────────────────────────────────────────────────
ilTopRow = 0 !
DO ShowTable !
!─────────────────────────────────────────────────────────────────────────
LastPage ROUTINE ! Display first page
!─────────────────────────────────────────────────────────────────────────
ilTopRow = RECORDS(tModules) - eScrlRows !
IF ilTopRow < 0 THEN ilTopRow = 0. !
DO ShowTable !
!─────────────────────────────────────────────────────────────────────────
NextPage ROUTINE ! Display next page
!─────────────────────────────────────────────────────────────────────────
ilTopRow += eScrlRows !
IF ilTopRow > RECORDS(tModules) - eScrlRows !
DO LastPage !
ELSE !
DO ShowTable !
. !
!─────────────────────────────────────────────────────────────────────────
PrevPage ROUTINE ! Display previous page
!─────────────────────────────────────────────────────────────────────────
IF ilTopRow > 0 !
ilTopRow -= eScrlRows !
IF ilTopRow < 0 THEN ilTopRow = 0. !
DO ShowTable !
. !
!─────────────────────────────────────────────────────────────────────────
MoveUp ROUTINE ! Move up one line
!─────────────────────────────────────────────────────────────────────────
IF ibRepNdx > 1 !
ibRepNdx -= 1 !
ELSIF ilTopRow > 0 !
ilTopRow -= 1 !
DO ShowTable !
. !
!─────────────────────────────────────────────────────────────────────────
MoveDown ROUTINE ! Move up down one line
!─────────────────────────────────────────────────────────────────────────
IF ibRepNdx < eScrlRows !
ibRepNdx += 1 !
ELSIF ilTopRow < RECORDS(tModules) - eScrlRows !
ilTopRow += 1 !
DO ShowTable !
. !
!─────────────────────────────────────────────────────────────────────────
GetRecord ROUTINE ! Get currently highlighted record
!─────────────────────────────────────────────────────────────────────────
GET(tModules, ilTopRow + ibRepNdx) ! Get record
!─────────────────────────────────────────────────────────────────────────
ShowTable ROUTINE ! Display current table page
!─────────────────────────────────────────────────────────────────────────
ibSavRepNdx = ibRepNdx ! Save repeat index
LOOP ibRepNdx = 1 TO eScrlRows ! Loop for each row
GET(tModules, ilTopRow + ibRepNdx) ! Get record
IF ERRORCODE() ! If not found
SCR:ssName = '' ! Blank screen line
ELSE ! Else
SCR:ssName = TMO:sName ! Set screen fields
SCR:ssStart = TMO:ilStart !
SCR:ssSize = TMO:ilSize !
. . ! End loop
DO Arrows ! Display scroll arrows
ibRepNdx = ibSavRepNdx ! Restore repeat index
!──────────────────────────────────────────────────────────────────────────
Arrows ROUTINE ! Display scroll arrows
!──────────────────────────────────────────────────────────────────────────
SCR:ssULArrow = ' ' !
SCR:ssLLArrow = ' ' !
IF ilTopRow > 0 !
SCR:ssULArrow = eUpArrow !
. !
IF ilTopRow + eScrlRows < RECORDS(tModules) !
SCR:ssLLArrow = eDnArrow !
. !
SCR:ssURArrow = SCR:ssULArrow !
SCR:ssLRArrow = SCR:ssLLArrow !
!═════════════════════════════════════════════════════════════════════════
! Extract selected object module from library
!═════════════════════════════════════════════════════════════════════════
ExtractMod PROCEDURE
! Locals:
ilOffset LONG !
! Screens:
wScreen SCREEN WINDOW(6,50),PRE(SCR),HUE(0,7)
ROW(1,1) STRING('┌<0{37}>─{11}┐')
ROW(2,1) REPEAT(4);STRING('│<0{48}>│') .
ROW(6,1) STRING('└─{48}┘')
ROW(1,4) STRING('Extracting Module:')
ssName COL(23) STRING(15),HUE(0,7)
ROW(4,4) STRING('Write .OBJ to what file?')
COL(29) ENTRY(@S20),USE(sgObjFName),HUE(0,3),SEL(14,4),REQ
.
CODE
OPEN(wScreen) !
SCR:ssName = TMO:sName !
LOOP !
ALERT !
ALERT(Esc_Key) !
ACCEPT !
IF KEYCODE() = Esc_Key THEN BREAK. !
OPEN(oObjFile) !
IF ERRORCODE() THEN BREAK. !
CLOSE(oObjFile) !
IF Confirm() THEN BREAK. !
. !
IF NOT KEYCODE() = Esc_Key !
CREATE(oObjFile); ChkErr() !
ilOffset = TMO:ilStart !
SET(oLibFile, ilOffset) !
LOOP WHILE (ilOffset - TMO:ilStart) < TMO:ilSize
NEXT(oLibFile) !
OOB:Record = OLF:Record !
ADD(oObjFile); ChkErr() !
ilOffset += SIZE(OLF:record) !
. !
CLOSE(oObjFile) !
. !
CLOSE(wScreen) !
RETURN !
!═════════════════════════════════════════════════════════════════════════
! Confirm overwrite of existing file
!═════════════════════════════════════════════════════════════════════════
Confirm FUNCTION
! Return:
bbRetVal BYTE !
! Screens:
wScreen SCREEN WINDOW(5,50),HUE(15,4)
ROW(1,1) STRING('╔═{48}╗')
ROW(2,1) REPEAT(3);STRING('║<0{48}>║') .
ROW(5,1) STRING('╚═{48}╝')
ROW(3,4) STRING('File already exists! Overwrite?')
COL(38) MENU,USE(?Menu),REQ
COL(38) STRING(' Yes '),SEL(0,7)
COL(44) STRING(' No '),SEL(0,7)
. .
CODE
bbRetVal = 0 !
OPEN(wScreen) !
ACCEPT !
IF CHOICE() = 1 THEN bbRetVal = 1. !
CLOSE(wScreen) !
RETURN( bbRetVal ) !
!═════════════════════════════════════════════════════════════════════════
! Check for errors
!═════════════════════════════════════════════════════════════════════════
ChkErr PROCEDURE
CODE
IF ERRORCODE() THEN STOP(ERROR()); RETURN.