$CPU 8086 ' make compatible with XT systems $LIB ALL OFF ' turn off all PowerBASIC libraries $ERROR ALL OFF ' turn off all PowerBASIC error checking $OPTIMIZE SPEED ' optimize for smaller code $COMPILE UNIT ' compile to a UNIT (.PBU) '$COMPILE EXE ' compile to a UNIT (.PBU) DEFINT A-Z ' Required for all numeric functions, forces PB to not ' include floating point in UNIT (makes it smaller) '/*----------------------------------------------------------------*/ DECLARE SUB BAR(TYP%,ROW%,COL%,LTH%,C$,C2$,ATTR%,ATTR2%,P%) DECLARE SUB TBOX(BYVAL ROW,BYVAL COL,BYVAL ROWS,BYVAL COLS,BYVAL ATTR,BYVAL OPT,BYVAL SHAD) DECLARE SUB SAY(BYVAL Row AS INTEGER, BYVAL Col AS INTEGER, BYVAL Text AS STRING, BYVAL Attr AS INTEGER) DECLARE SUB MClicked(Rgt%,Lft%,Row%,Col%) DECLARE SUB MOUSEOFF() DECLARE SUB MOUSEON() DECLARE FUNCTION ISMOUSELBR() '/*-----------------------------------------------------------------*/ $CODE SEG "MLIB1" '/*-----------------------------------------------------------------*/ ' BROWSE(ROW,COL,ATTR,STRING,NROWS,NCOLS,KEY$,BOXATTR,BOXTYPE,MF) ' Displays a "binary" STRING where the individual records are ' delimited by CR/LF. Returns exiting key. ' ROW = Top row to start display. If 0 then row centering is used. ' COL = Left columns to begin display. If 0 then column centering ' is used. ' ATTR = Color of text in browse window. ' STRING = Binary string to be displayed. ' NROWS = Number of rows to display. ' NCOLS = Number of Columns to Display. ' KEY$ = Keys that will exit browse. ESC is the default. ' BOXATTR = Color of Box Lines. ' BOXTYPE = Type of box lines. See TBOX for types. ' MF = Use Mouse: ' 0 = No ' 1 = Yes ' Place mouse cursor on Top line to scroll up when ' pressing left or right mouse button. ' Place mouse cursor on Bottom line to scroll up when ' pressing left or right mouse button. ' Place mouse on left line or right to while pressing ' left or right mouse button to scroll left and right. ' Place mouse cursor in upper left corner and press ' left mouse button to exit browse. ' EXAMPLE: T$ = BROWSE(3,3,31,F$,22,78,CHR$(0,61),14,1,1) ' | | | | | | | | | | | | +- Use Mouse ' | | | | | | | | | | | +- Box Type ' | | | | | | | | | +- Color of Lines ' | | | | | | | | + Exit when F3 key is pressed ' | | | | | | | +-- Last Display Column ' | | | | | | +----- Last Display Row ' | | | | | +------- First Display Column ' | | | | +--------- First Display Row ' | | | +------------ String to Display (BINARY) ' | | +--------------- Text Color ' | +------- First Display Column ' +--------- First Display Row ' ' The text in the browse window is moved via: ' Up/Down Arrows = one line at a time ' UP/Down Page = one page at a time ' Home = first page/fist column ' Ctrl-Left Arrow = Tab left 10 columns ' Ctrl-Right Arrow = Tab Right 10 columns ' Ctrl-Home = Return to first column ' ' NOTE: String to be display must be less then the maximum set ' for PowerBASIC (defualt is 32000). ' '/*-----------------------------------------------------------------*/ FUNCTION BROWSE(BYVAL ROW, BYVAL COL, BYVAL ATTR, BYVAL A$, BYVAL NROWS, BYVAL NCOLS, BYVAL K$, BYVAL BOXATTR%, BYVAL BOXTYPE%, BYVAL DMOUSE%) PUBLIC AS STRING '/*--- Center Browse Box? ---*/ IF ROW = 0 THEN ROW = 12 - (NROWS/2) END IF IF ROW < 1 THEN ROW = 1 '/* NROWS = ROW + NROWS IF COL = 0 THEN COL = 40 - (NCOLS/2) END IF IF COL < 1 THEN COL = 1 '/* NCOLS = COL + NCOLS TopRow% = ROW BottomRow% = NROWS +ROW RightColumn% = NCOLS + COL LeftColumn% = COL '/*--- Put Box on Screen ---*/ '/* BBOX ROW, COL, NROWS, NCOLS, BOXATTR%, BOXTYPE%, 0 TBOX ROW,COL,NROWS,NCOLS,BOXATTR%,BOXTYPE%,0 IF DMOUSE% > 1 THEN BLTH =NROWS-ROW-2 TBAR = ROW+1 IF BLTH < 3 THEN BLTH = 0 END IF '/*--- Initialize Vars ---*/ SHARED Boffset% :'/* horizontal movement IF BOXTYPE% < 15 THEN ROW = TopRow%+1 NROWS = BottomRow% - 1 END IF IF BOXTYPE% < 13 THEN INCR COL DECR NCOLS END IF WideNess%=NCOLS -1 :'/* -COL+1 IF BOXTYPE = 15 THEN NROWS = BottomRow% BLTH = 0 END IF '/*--- Check for Termination Keys ---*/ IF K$ = "" THEN K$ = CHR$(27) 'Boffset%=10 :'/* horizontal movement MAL = LEN(A$) Ptr% = 1 DO IF DMOUSE% THEN MOUSEOFF TempPtr% = Ptr% : Temp% = ROW DO '/* --- TempPtr% is byte position of current line, calculate offset of end of line eol% = Instr(Mid$(A$,TempPtr%),Chr$(13)) '/* ---if there are no more carriage returns, then eol% is the end of A$ if eol%=0 then eol%=LEN(A$) ELSE DECR eol% :'/* DECR: do not show the CR '/* --- get the current line as Curr$ Curr$ = Mid$(A$, TempPtr%,eol%) '/* --- display the current line SAY Temp%, COL, Mid$(Curr$+Space$(WideNess%+Boffset%), 1+Boffset%,WideNess%), ATTR '/* --- increment the pointer to the next line to display in the window TempPtr% = Instr(TempPtr%, A$, Chr$(13)) + 2 ' +2 for CRLF pair '/* --- if we have reached the end then we don't show any more If TempPtr%=2 Then TempPtr%=LEN(A$) '/* --- get ready to display the next line... INCR Temp% if Temp% > NROWS -1 THEN Exit LOOP LOOP '/*--- Display Scroll Bar ---*/ IF BLTH > 0 THEN IF TempPtr% => MAL THEN P = 100 ELSE P = (Ptr%/MAL)*100 BAR 1,TBAR,NCOLS,BLTH,CHR$(176),CHR$(254),BOXATTR%,BOXATTR%,P END IF '/*--- Check Mouse Until Key is Pressed ---*/ WHILE NOT INSTAT IF DMOUSE% THEN MOUSEON Rgt% = 0:Lft% = 0:MRow% = 0:MCol% = 0 MCLICKED Rgt%,Lft%,MRow%,MCol% '/* --- Exit? --- IF MCol% = LeftColumn% AND MROW = TopRow% AND ISMOUSELBR THEN KB$ = CHR$(27): GOTO KeyBoardRoutine '/* --- Left Mouse Button Pressed? --- IF Lft% THEN '/* --- Left Arrow? --- IF MCol% = LeftColumn% THEN KB$ = CHR$(0,75): GOTO KeyBoardRoutine '/* --- Right Arrow? --- IF MCol% = Rightcolumn% THEN KB$ = CHR$(0,77): GOTO KeyBoardRoutine '/* --- Up Arrow? --- IF MRow% = TopRow% THEN KB$ = CHR$(0,72): GOTO KeyBoardRoutine '/* --- Down Arrow? --- IF MRow% = BottomRow% THEN KB$ = CHR$(0,80): GOTO KeyBoardRoutine END IF '/* --- Right Mouse Button Pressed? --- IF Rgt% THEN '/* --- Left Tab? --- IF MCol% = LeftColumn% THEN KB$ = CHR$(0,15): GOTO KeyBoardRoutine '/* --- Right Tab? --- IF MCol% = Rightcolumn% THEN KB$ = CHR$(9): GOTO KeyBoardRoutine '/* --- Up Page? --- IF MRow% = TopRow% THEN KB$ = CHR$(0,73): GOTO KeyBoardRoutine '/* --- Down Page? --- IF MRow% = BottomRow% THEN KB$ = CHR$(0,81): GOTO KeyBoardRoutine END IF END IF WEND KB$ = INKEY$ KeyBoardRoutine: S = INSTR(1,K$,KB$) IF S > 0 THEN EXIT LOOP SELECT CASE KB$ CASE CHR$(0,&H50) :'/*dn arrow IF TempPtr% < LEN(A$) THEN Ptr%=Instr(Ptr%, A$, Chr$(13) ) + 2 ELSE Sound 100,.1 :'/* we are at the end END IF CASE CHR$(0,&H48) :'/*up arrow IF Ptr% > 1 THEN '/* --- search backwards for a CR or 1 --- DECR Ptr%:IF Ptr%>1 then DECR Ptr% DO:DECR Ptr%:LOOP UNTIL Mid$(A$, Ptr%, 1)=CHR$(13) OR Ptr%=1 IF Ptr%>1 THEN INCR Ptr%:INCR Ptr% ELSE Sound 100,.1 :'/*we are at the beginning END IF CASE CHR$(0,&H47) :'/*home If Boffset% THEN Boffset% = 0 ELSE Ptr%=1 CASE CHR$(0,119) :'/*Control Home Boffset% = 0 CASE CHR$(09), CHR$(00,116) :'/* Tab Right - Move 10 spaces right Boffset% = Boffset% + 10 CASE CHR$(0, &H4D) :'/* right arrow INCR Boffset% CASE CHR$(0,&H4B) :'/* left arrow If Boffset% THEN DECR Boffset% CASE CHR$(00,15),CHR$(00,115) :'/*Tab Left - Move 10 spaces left Boffset% = Boffset% - 10 IF Boffset% < 0 THEN Boffset% = 0 CASE CHR$(0,&H51) :'/* page down IF TempPtr% < LEN(A$) THEN FOR pd = ROW to NROWS-1 OldPtr%=Ptr% Ptr%=Instr(Ptr%, A$, Chr$(13) ) + 2 if Ptr%=2 then Ptr%=OldPtr%:Exit FOR Next Pd ELSE Sound 100,.1 :'/* we are at the end END IF CASE CHR$(0,79) :'/*End Ptr% = MAL GOTO BICJ CASE CHR$(0, &H49) :'/* page up BICJ: FOR pd = ROW to NROWS -1 IF Ptr% > 1 THEN '/* --- search backwards for a CR or 1 --- DECR Ptr%:IF Ptr%>1 then DECR Ptr% DO:DECR Ptr%:LOOP UNTIL Mid$(A$, Ptr%, 1)=CHR$(13) OR Ptr%=1 IF Ptr%>1 THEN INCR Ptr%:INCR Ptr% ELSE Sound 100,.1 :'/*we are at the beginning EXIT FOR END IF NEXT Pd CASE ELSE END SELECT LOOP IF DMOUSE% THEN MOUSEOFF FUNCTION = KB$ END FUNCTION '/*----------------------------------------------------------------*/ ' $INCLUDE "C:\CODE\MLIB\MLIB.INC" ' CLS 'DO ' F$ = F2BS("g:\batch\normal.BAT") ' KT$ = CHR$(27) + CHR$(00,62) ' T$ = BROWSE(1,1,31,F$,25,80,KT$,12,1,1) 'LOOP UNTIL T$ = CHR$(00,62)