Mktkxoi&K^ZXG&vxumxgs&zu&giikyy&jgzg|{k&lorkyZos&Igvvy(=v$*=w# �D AU.......|.......|.......|.......|.......|.......|.......|.......|...............................................................
;
; Generic DataVUE file access command
;
; Written by Tim Capps, 8/29/86
;
; - Modified for use by DVLOOK - TCC
;
do dv
'crt clear
'print "Loading DataVUE file..."
'display-off
'trap done
'arguments file ; Get the file name
;;; display-off
'xbuf=file
'text "fetch ^S^O^M" ; Load the file
;;; display-pos
'dv-open file ; Open the file
'ifne
)crt 6,1 ; Too bad.
)crt eos
)print "Cannot load DataVUE file: ";file
)goto done
; crt 5,1
; print ">"; ; Redisplay the prompt
; stop
'endif
;
; Find out about this file
;
'MAX'C=0 ; Max. column number.
'C'WIDTH=0 ; Widest column title.
d'names:
'MAX'C=MAX'C+1 ; Count another column.
'cmpnum MAX'C,20 ; Clamp to 20 column names.
'ifle
)TEMP="("&MAX'C&")" ; Build the column name.
)dv-column TEMP ; Zip to the next column.
)ifeq ; Does it exist?
+dv-columnname XBUF ; Yes, get the column name.
+len XBUF,ACC
+cmpnum ACC,C'WIDTH ; Does this column have widest name?
+ifgt
-C'WIDTH=ACC ; New widest column name.
+endif
+goto d'names ; Loop for next column.
)endif
'endif
'MAX'C=MAX'C-1 ; MAX'C now = the # of columns (<=20)
'; We now know the # of columns, and the width of the widest name
'S'COL=1 ; Default to first column for searches
repaint:
'display-pos
'crt clear
'call display'names ; Display the column names
new'rec:
'call display'data ; display the current DataVUE record.
wait:
'input 24 ^_ "Enter command (or ? for help): " E^JKLHXC[
'message "" ; Clean up line 25
;
; Figure out what they want to do.
;
'cmd=xbuf[1,1] ; Get the first letter
'ucs cmd ; Fold it for comparisons
'cmpstr xchar,"^[" ; ESC (terminate)?
'beq done
'cmpstr xchar,"^C" ; ^C
'beq done
'cmpstr cmd,"Q" ; QUIT?
'beq done
'cmpstr xchar,"^^" ; Home?
'ifeq
)dv-first
)goto new'rec
'endif
'cmpstr xchar,"^E" ; End of file?
'ifeq
)dv-last
)goto new'rec
'endif
'cmpstr xchar,"^J" ; DOWN (next record)
'ifeq
)dv-next ; Skip to the next record
)ifne
*dv-first ; Whoops! End of file, wrap around
*beep ; to the top.
)endif
)goto new'rec
'endif
'cmpstr xchar,"^K" ; UP
'ifeq
)dv-previous ; Back up one record
)ifne
+dv-last ; Wrap to the bottom if we hit the top
+beep
)endif
)goto new'rec
'endif
'cmpstr cmd,"H"
'oreq
'cmpstr cmd,"?" ; Help?
'ifeq
)call help ; Display the help screen
)goto repaint ; Repaint the entire screen
'endif
'cmpstr xchar,"^L" ; Move key pointer down
'ifeq
)crt S'COL,1
)print " "; ; Erase the old one
)S'COL=S'COL+1
)cmpnum S'COL,MAX'C
)ifgt
+S'COL=1 ; Wrap around
)endif
)crt S'COL,1
)print "->"; ; Put up the new one
)goto wait
'endif
'cmpstr xchar,"^H" ; Move key pointer up
'ifeq
)crt S'COL,1
)print " "; ; Erase the old one
)S'COL=S'COL-1
)cmpnum S'COL,0
)ifeq
+S'COL=MAX'C ; Wrap around
)endif
)crt S'COL,1
)print "->"; ; Put up the new one
)goto wait
'endif
'cmpstr cmd,"S" ; Search?
'ifeq
)X=1 ; Find the end of the command
)instr X,xbuf," "
)ifeq
+xbuf=xbuf[X,-1] ; Get the search string
+byp xbuf ; Skip the leading spaces
)else
+xbuf="" ; No string given, let's get one!
)endif
)cmpstr xbuf,"" ; Did we get a string?
)ifeq
+input 24 ^_ "Search for? " ; No, ask for one.
)endif
)temp="("&S'COL&")" ; Make the column name
)dv-column temp
)dv-search xbuf
)ifne
*beep
*message "Cannot find requested record."
*goto wait
)endif
)goto new'rec ; Got one!
'endif
'cmpstr xchar,"^X"
'oreq
'cmpstr cmd,"N" ; Next?
'ifeq
)dv-search-next ; Get next record
)ifne
+beep
+message "No more records in sequence."
+goto wait
)endif
)goto new'rec ; Got another
'endif
'message "Invalid command - press ? for help"
'beep
'goto wait
;
; All finished.
;
done:
;; dmode
;; stop
'crt clear
'print "Returning to AMOS"
'display-off
'text "NC^MQ^M"
'stop
;
; Display the column names (and put -> next to the current search field)
;
display'names:
'crt home
'X=1
DDN'LOOP:
'xbuf="("&X&")"
'dv-column xbuf ; Set the column
'dv-columnname xbuf ; Get it's name
'len XBUF,Y ; Find out how long this text is.
'Z=C'WIDTH+1 ; Right justify it
'Y=Z-Y ; Y=# of spaces needed on the front
'cmpnum Y,0 ; Do we need any?
'ifne
)loop Y
+xbuf=" "&xbuf ; Add a leading space.
)next
'endif
'cmpnum X,S'COL ; Is this our current search column?
'ifeq
)print "->";
'else
)print " ";
'endif
'print xbuf;":"
'X=X+1 ; Next column please.
'cmpnum X,MAX'C ; Are we done?
'jle DDN'LOOP ; No, loop for more.
'return ; Yes.
;
; Display the current DataVUE record.
;
display'data:
'X=1
DD'LOOP:
'Z=C'WIDTH+6 ; Display to the right of the name
'crt X,Z
'xbuf="("&X&")" ; Build the column name
'dv-get xbuf,xbuf ; Get the data into xbuf
'crtcol Y ; Get the current screen width
'Y=Y-X-2 ; Maximum width of data
'print xbuf[1,Y]; ; Display and truncate to screen width
'crt eol
'X=X+1 ; Next column please.
'cmpnum X,MAX'C ; Are we done?
'jle DD'LOOP ; No, loop for more.
'return ; Yes.
;
; Display some help
;
help:
'crt clear
'print "DataVUE access commands:"
'print
'print "Home Top of file"
'print "Control-K Previous record (up arrow)"
'print "Control-J Next record (down arrow)"
'print "Control-E End of file (last record)"
'print
'print "Control-L Change search key field down (right arrow)"
'print "Control-H Change search key field up (left arrow)"
'print
'print "S Search current key field"
'print "N Search for next occurance"
'print "Control-X Search for next occurance"
'print
'print "H Display this help screen"
'print "? Display this help screen"
'print
'print "Q Quit"
'print "Escape Quit"
'crt 24,1
'print "Press any key to continue: ";
'pause
'return
'map S'COL,10 ; Current search column
'map MAX'C,10 ; Max column number in use in DV file
'map C'WIDTH,10 ; Max column name width
'map X,10 ; Scrap
'map Y,10 ; Scrap
'map Z,10 ; Scrap
'map TEMP,20 ; Temp area for building column names
'map FILE,40 ; Name of the file we are viewing
'map CMD,2 ; First letter of command for comparisons