home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
High Voltage Shareware
/
high1.zip
/
high1
/
DIR4
/
VIEWSRCH.ZIP
/
VSEARCH.TPX
< prev
Wrap
Text File
|
1993-10-27
|
19KB
|
411 lines
#!-------------------------------------------------------------------------------#!
#! VSEARCH.TPX
#!
#! ViewAndSearch View a selected text file in a listbox w/search
#!
#!------------------------------------------------------------------------------
#PROCEDURE(ViewAndSearch,'View a selected text file in a listbox'),SCREEN,REPORT,PULLDOWN
#!------------------------------------------------------------------------------
#!
#! The View And Search Template
#!
#!------------------------------------------------------------------------------
#PROTOTYPE('')
#MAP('GETLIST.INC')
#PROJECT('%clapfx%ASCII.LIB')
#INSERT(%StandardHeader)
#DISPLAY(' ')
#PROMPT('File to &View',@s30),%ListFile
#PROMPT('Warning Size (in K)',@s6),%FileWarningSize
#PROMPT('Ma&ximum Line Length',@s6),%FileLineLength
#PROMPT('Progress &Indicator',CHECK), %ShowProg
#PROMPT('Progress Character',@S8),%ProgChar
#PROMPT('Always Show Pulldown',CHECK),%AlwaysPulldown
#!
#IF(%ListFile = %Null)
#SET(%ListFile, 'GLO:FileSpec')
#ENDIF
%Procedure PROCEDURE
%LocalData
SaveRows BYTE !Initial screen rows
SaveCols BYTE !Initial screen columns
FirstPage BYTE !First page display flag
FieldNo USHORT !Equate of List Box
Bar USHORT !Position in Queue
Elem USHORT !Element of List Box
CaseSensitive BYTE(0) !Type of Search
SearchFor CSTRING(21) !What to Search for
SaveStyle STRING(256) !Save Colour Scheme
! File to View, With 3K of buffering
RptFile FILE,DRIVER('ASCII','/FILEBUFFERS=6'),NAME(%ListFile),PRE(Dos) #<! Declare Input File
RECORD
#IF(%FileLineLength)
Fline STRING(%FileLineLength)
#ELSE
Fline STRING(255)
#ENDIF
. .
SaveScreen SCREEN(25,80).
%ReportStructure
SCREEN %ScreenAttributes
%ScreenPaintDeclarations
%ScreenStringDeclarations
Entry,Use(?FIRST_FIELD)
%ScreenFieldDeclarations
.
SearchInput SCREEN(13,45),CENTER,SHADOW,FALL,CUA,COLOR(112)
!dimensions=25,80,25,80
ROW(1,1) STRING('█{45}'),COLOR(121)
ROW(4,6) STRING('What phrase should be searched for?')
ROW(13,1) STRING('█▄{43}█'),COLOR(121)
REPEAT(11)
ROW(2,1) STRING('█'),COLOR(121)
ROW(2,45) STRING('█'),COLOR(121)
.
ROW(4,45) ENTRY(),USE(?FirstField),COLOR(126,7,120)
ROW(6,13) ENTRY(@S20),USE(SearchFor),COLOR(113,7,120)
ROW(8,14) CHECK('Case Sensitive'),USE(CaseSensitive),COLOR(112,7,120,127,15)
ROW(11,11) BUTTON(' &Ok '),SHADOW,KEY(EnterKey),USE(?Ok2),COLOR(23,71,24,31,79)
COL(28) BUTTON(' E&xit '),SHADOW,KEY(EscKey),USE(?Exit2),COLOR(23,71,24,31,79)
.
#IF(%ShowProg)
VEW::Length BYTE !Progress variable
VEW::ProgString STRING('»{50}') !Progress display variable
#ENDIF
#EMBED('Data Section')
CODE
#EMBED('Setup Procedure')
#IF(%ProgChar) #!If showing the progress
VEW::ProgString = ALL(%ProgChar) #<!Fill the progress string
#ENDIF
IF NOT %ListFile THEN RETURN. #<!If %ListFile is blank
FieldNo=?List
OPEN(RptFile) !Open the Dos File
IF DiskError('Cannot Locate Selected File') THEN RETURN.
OldState#=SEND (RptFile, 'QUICKSCAN=ON') ! Faster Access
#IF(%FileWarningSize)
IF Bytes(RptFile) > (%FileWarningSize * 1024)#<!If oversized file
GLO:Message1 = 'This is a large file and may take a while'
GLO:Message2 = 'to load. You may press the Esc key'
GLO:Message3 = 'while the file is loading to exit.'
ShowWarning ! Show a warning screen
END !End IF
#ENDIF
IF GRAPHIC(1) = 5Ah !If in text mode
OPEN(SaveScreen) ! Open a save screen
END !End IF
OPEN(Screen) !Open the Screen
#SET(%PrintFieldExists,'')
#FOR(%ScreenField)
#IF(%ScreenField = '?PrintDevice')
DISABLE(?PrintDevice) !Disable the device field
#ENDIF
#IF(%ScreenField = '?Print')
#SET(%PrintFieldExists,'True')
#ENDIF
#IF(%ScreenField = '?ChangeMode')
IF GRAPHIC(1) <> 5Ah !If not in text mode
DISABLE(?ChangeMode) ! Disable changemode button
END !End IF
#ENDIF
#ENDFOR
#IF(%Pulldown) #!If a Pulldown exists
#IF(%AlwaysPulldown) #!If a Pulldown exists
OPEN(%Pulldown,1) #<!Open the Pulldown Always
#ELSE
OPEN(%Pulldown) #<!Open the Pulldown
#ENDIF
#ENDIF
SaveRows = Rows(SCREEN) !Save the Screen Rows
SaveCols = Cols(SCREEN) !Save the Screen Columns
#EMBED('Setup Screen')
FirstPage = 1 !Set flag for Page 1
SET(RptFile) !Set to the file
LOOP !Loop through the dos file
#INSERT(%GenerateFormulas)
#EMBED('Top of Accept Loop')
NEXT(RptFile) ! Get the next record
IF ERRORCODE() THEN BREAK. ! Break if error occurs
#IF(%FileLineLength)
IF Bytes(RptFile) > %FileLineLength ! Line is longer than allowed
GLO:Message1 = 'The line length is greater than %FileLineLength.'
#ELSE
IF Bytes(RptFile) > 255 ! Line is longer than allowed
GLO:Message1 = 'The line length is greater than 255.'
#ENDIF
GLO:Message2 = 'The selected file is not an ASCII file.'
GLO:Message3 = 'No view on this file is available.'
ShowWarning ! Show an error message
FREE(ListQueue) ! Free memory table
CLOSE(RptFile) ! Close the DOS file
#IF(%Pulldown) #!If a Pulldown exists
CLOSE(%Pulldown) #<! Close the Pulldown
#ENDIF
CLOSE(SCREEN) ! Close the Screen
#EMBED('Immediately before RETURN for non-ASCII file error')
RETURN ! Return back to caller
END !End IF
#IF(%ShowProg) #!If showing the progress
#INSERT(%ShowProgress)
#ENDIF
#EMBED('After NEXT in RptFile LOOP')
Que:QueueLine = Dos:Fline ! Fill the queue line.
ADD(ListQueue) ! Add to the queue
IF ERRORCODE() ! If out of memory
GLO:Message1 = 'Error: ' & ERROR() ! Create the error message
GLO:Message2 = 'This file is too large to be read into memory.'
GLO:Message3 = 'The entire file will not be displayed.'
ShowWarning ! Show the error message
BREAK ! Break out of read loop
END ! End IF
IF FirstPage ! If page 1
IF RECORDS(ListQueue) = ROWS(SCREEN) ! If we have a full screen
FirstPage = 0 ! Turn off the page flag
DISPLAY(?List) ! Display page 1
END ! End IF
END ! End IF
LOOP WHILE KEYBOARD() ! While Keyboard Input
SELECT(?List) ! Select the List box
ACCEPT ! Handle internal keystrokes
END ! End LOOP
IF KEYCODE() = EscKey THEN BREAK.
END !End LOOP
StatusLine = 'Viewing: ' & %ListFile #<!Fill the status line
DISPLAY !Redisplay the screen
PrintDevice = '' !Blank the PrintDevice field
LOOP !Process the screen
#FOR(%ScreenField)
#IF(%ScreenFieldSetup)
CASE SELECTED() #<! Jump to field setup routine
#INSERT(%ScreenSetupRoutines)
END #<! End CASE
#ENDIF
#ENDFOR
ACCEPT ! Accept keyboard input
IF KEYCODE()=CtrlEsc OR (KEYCODE()=EscKey AND FIELD()=1)
BREAK ! Allow 2.1 style exit
.
#INSERT(%HotKeyRoutines)
CASE FIELD() ! Which field was completed
#FOR(%ScreenField)
#IF(%ScreenField = '?Exit')
OF ?Exit ! Completed Exit Button
#IF(%ScreenFieldEdit)
%ScreenFieldEdit #<! Exit edit routine
#ENDIF
BREAK ! Break out of the loop
#ELSIF(%ScreenField = '?Next')
OF ?Next
#IF(%ScreenFieldEdit)
%ScreenFieldEdit #<! Edit routine
#ENDIF
GetList(FieldNo,Bar,Elem)
DO SearchText
#ELSIF(%ScreenField = '?Search')
OF ?Search
#IF(%ScreenFieldEdit)
%ScreenFieldEdit #<! Edit routine
#ENDIF
GetList(FieldNo,Bar,Elem)
SaveStyle = STYLES() #<!Save current style
GETSTYLES('') #<!Turn off Styles
OPEN(SearchInput)
LOOP !Process the screen
ACCEPT ! Accept keyboard input
IF KEYCODE()=EscKey OR KEYCODE()=CtrlEsc OR FIELD()=?Exit2
BREAK ! Used for 2.1 style
. ! screens
IF KEYCODE()=CtrlEnter OR FIELD()=?Ok2 OR KEYCODE()=EnterKey
BREAK
.
.
SETSTYLES(SaveStyle) #<!Restore user styles
IF KEYCODE()=EscKey OR KEYCODE()=CtrlEsc OR FIELD()=?Exit2
CLOSE(SearchInput)
CYCLE
.
CLOSE(SearchInput)
DO SearchText
#ELSIF(%ScreenField = '?ChangeMode')
OF ?ChangeMode ! Completed mode button
IF ROWS(SCREEN) = 25 ! If in 25 line mode
CLOSE(SCREEN) ! Close the current screen
SETTEXT(50,80) ! Set to 50 line mode
ELSE ! Else in 43 or 50 line mode
CLOSE(SCREEN) ! Close the current screen
SETTEXT(25,80) ! Set to 25 line mode
SETAREA(25,80) ! Resize the screen area
LOADSYMBOLS ! Reload graphic mouse
END ! End IF
OPEN(SCREEN) ! Open screen in new mode
#FOR(%ScreenField)
#IF(%ScreenField = '?PrintDevice')
DISABLE(?PrintDevice) ! Disable the device field
#ENDIF
#IF(%ScreenField = '?ChangeMode')
IF GRAPHIC(1) <> 5Ah ! If not in text mode
DISABLE(?ChangeMode) ! Disable ChangeMode button
END ! End IF
#ENDIF
#ENDFOR
#IF(%MouseSupport)
SETMOUSE(ROW(?ChangeMode),COL(?ChangeMode))! Reset the mouse position
#ENDIF
#IF(%ScreenFieldEdit)
%ScreenFieldEdit #<! ChangeMode edit routine
#ENDIF
DISPLAY ! Display the fields
PrintDevice = '' ! Blank PrintDevice field
#ELSIF(%ScreenField = '?Print')
OF ?Print ! Completed Print Button
#IF(%ScreenFieldEdit)
%ScreenFieldEdit #<! Print button edit routine
#ENDIF
IF NOT PrintDevice ! If no print device
DISABLE(?StatusLine) ! Disable the StatusLine
ENABLE(?PrintDevice) ! Enable the PrintDevice
SELECT(?PrintDevice) ! Select the PrintDevice
CYCLE ! Cycle to ACCEPT input
END ! End IF
IF NOT STATUS(PrintDevice) ! If PrintDevice not ready
GLO:Message1 = CLIP(PrintDevice) & ' is not ready.'
GLO:Message2 = 'Be sure the Printer is online and attached to'
GLO:Message3 = 'the specified device and try again.'
ShowWarning ! Show an error message
PrintDevice = '' ! Blank PrintDevice field
CYCLE ! Cycle to ACCEPT input
END ! End IF
StatusLine = 'Printing: ' & %ListFile #<! Fill the status line
DISPLAY(?StatusLine) ! Display the status line
OPEN(REPORT) ! Open the report to print
LOOP I# = 1 to RECORDS(ListQueue) ! Loop while QUEUE records
GET(ListQueue,I#) ! Get the QUEUE entry
IF ERRORCODE() THEN BREAK. ! Break if an error occurs
%ReportDetailPre
PRINT(%ReportPre:%ReportDetail) #<!Print Detail band
%ReportDetailPost
IF KEYBOARD() ! If keyboard input
ACCEPT ! Get the keystroke
IF KEYCODE() = EscKey ! If the ESCAPE key
PrintDevice = '' ! Blank PrintDevice field
BREAK ! Break from printing
END ! End IF
END ! End IF
END ! End LOOP
CLOSE(REPORT) ! Close the report
StatusLine = 'Viewing: ' & %ListFile #<! Fill the status line
DISPLAY(?StatusLine) ! Display the status line
PrintDevice = '' ! Blank PrintDevice field
#ELSIF(%ScreenField = '?PrintDevice')
OF ?PrintDevice ! Selected a port for printer
#IF(%ScreenFieldEdit)
%ScreenFieldEdit #<! PrintDevice edit routine
#ENDIF
DISABLE(?PrintDevice) ! Disable the PrintDevice
ENABLE(?StatusLine) ! Enable the StatusLine
IF KEYCODE() = EscKey ! If escape key pressed
SELECT(?Exit) ! Select the exit button
PrintDevice = '' ! Blank PrintDevice field
CYCLE ! Cycle to ACCEPT input
END ! End IF
#IF(%PrintFieldExists='True')
SELECT(?Print) ! Select the Print button
#ENDIF
PRESS(EnterKey) ! And complete it.
#ELSIF(%ScreenFieldEdit)
OF %ScreenField ! Completed %ScreenField
%ScreenFieldEdit ! %ScreenField edit routine
#ENDIF
#ENDFOR
#INSERT(%PulldownEditRoutines)
END ! End CASE FIELD()
END !End LOOP
#EMBED('Immediately after LOOP, before FREE(Queue)')
FREE(ListQueue) !Free memory table
CLOSE(RptFile) !Close the DOS file
#IF(%Pulldown) #!If a Pulldown exists
CLOSE(%Pulldown) #<!Close the Pulldown
#ENDIF
IF Rows(SCREEN) <> SaveRows | !If the mode is not the same
OR SaveCols <> Cols(SCREEN) ! as when procedure started
CLOSE(SCREEN) !Close the Screen
SETTEXT(SaveRows,SaveCols) ! Reset to the entry mode
SETAREA(SaveRows,SaveCols) ! Resize the screen area
LOADSYMBOLS ! Reload graphic mouse
END !End IF
#FOR(%ScreenField)
#IF(%ScreenField = '?Search')
SearchText ROUTINE ! Routine to Search Text
IF ~CaseSensitive
SearchFor=UPPER(SearchFor)
.
SaveElem#=Elem
SaveBar#=Bar
Found#=0
LOOP
Elem+=1
Get(ListQueue,Elem+Bar-1) ! Get Next Line
#EMBED('Searching, after Get List')
IF ERRORCODE() ! End, or other Error?
BREAK ! We're Done!
.
IF INSTRING(SearchFor,Que:QueueLine,1)>0 OR (~CaseSensitive AND INSTRING(SearchFor,UPPER(Que:QueueLine),1)>0)
DISPLAY
Found#=1 ! Found Text
BREAK
. .
IF Found#
SetList(FieldNo,Bar,Elem) ! Set LISTBOX to new position
#EMBED('Found, after Set List')
DISPLAY
ELSE
Elem=SaveElem# ! Set LISTBOX to old position
Bar=SaveBar#
Get(ListQueue,Elem+Bar-1)
#EMBED('Not Found - Get List')
StatusLine=SearchFor&' Not Found. {50}'
DISPLAY
.
SELECT(?List)
#ENDIF
#ENDFOR
#EMBED('End of Procedure')
#!
#!***************************************************************************
#!
#GROUP(%ShowProgress)
IF NOT (((POINTER(RptFile)+100)%%100)) !Show the progess indicator
VEW::Length += 1
StatusLine = ' Reading File: ' & SUB(VEW::ProgString,1,VEW::Length)
IF VEW::Length = 50
VEW::Length = 1
StatusLine = ' Reading File: ' & ' {70}'
END
Display(?StatusLine)
END
#!
#!***************************************************************************