home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
World of Shareware - Software Farm 2
/
wosw_2.zip
/
wosw_2
/
QBAS
/
PRLIST.ZIP
/
PRLIST.BAS
Wrap
BASIC Source File
|
1990-03-31
|
8KB
|
234 lines
DEFINT A-Z
DECLARE SUB Prlist (List$(), ListN%, NumInCols%, NumOfCols%, ColW%, Row%, Col%(), KeyCode%, ArrayNum%, Fg%, Bg%)
'PRLIST.BAS, 3/31/90
'by Gaylon Hill, Route 3, Box 311, Louisville, Tn 37777
'
'A sub program to print a list of string arrays to the screen
'in column formats. An array can be selected by using the arrows
'keys (Home, End, PgUp, PgDn), or by the first letter of the string array.
'The string array can be buffered with leading blanks, however, the sub
'will still select by the first letter after the leading blanks.
'
'CALL Prlist (List$(), ListN, NumInCols, NumOfCols, ColW, Row, Col(),_
' KeyCode, ArrayNum, Fg, Bg)
'List$() = array string list to be displayed.
'ListN = number of arrays.
'NumInCols = number of arrays to be displayed in each column.
'NumOfCols = number of columns to be displayed on each screen.
'ColW = the width of each column.
'Row = the screen row where the columns will start.
'Col() = an integer array that contains the starting place
' of each column.
' EX: DIM Col(1 TO 3): Col(1) = 5: Col(2) = 45: Col(3) = 60
'KeyCode = the returned code that caused the sub program to end.
' If the KeyCode in the CALL = 1 then the array strings is
' is displayed and the SUB is exit immediately (KeyCode then
' returns a 0 value, and the highlighted line is not displayed).
' If the KeyCode in the CALL = 2 then the array strings is
' is displayed with last string array shown and the SUB
' is exit immediately (KeyCode then returns a 0 value, the
' highlighted line is not displayed). If the KeyCode = 3 then
' a highlight line is not displayed, and the SUB is not exit.
' (KeyCode the returns a 0 value)
' The F1 key will exit the program and return a KeyCode value
' of 59. Keys that will exit the program are ENTER, ESC, F1,
' F2, F3, F4, F5, F6, F7, F8, F9, F10
'ArrayNum = the returned array number on exit of SUB program.
' If ArrayNum in the CALL = a minus number then the page
' with the selected array string is display.
' EX: ArrayNum = -100 'array number 100 will be displayed
' instead of starting at array number 1, however array
' number 100 may not be the first array in the first
' column.
'Fg = foreground color to print array strings.
'Br = background color to print array strings.
'
'Note: If an array string (List$()) is a NULL then that place on the screen
' where that array would have been printed is not used. Please note
' that the first array and the last array in the list should always
' contains data.
'EXAMPLE 1
CLS
DIM List$(1 TO 10), Col(1 TO 5)
FOR x = 1 TO 10
READ List$(x)
NEXT
LOCATE 20, 10: PRINT "USE ( Arrow, PgUp, PgDn, Home, End, Enter, F1,"
LOCATE 21, 19: PRINT "F2, F3, F4, F5, F6, F7, F8, F9, F10 ) KEYS"
LOCATE 22, 19: PRINT "or"
LOCATE 23, 19: PRINT "select by first letter of name"
ListN = 10: NumInCols = 6: NumOfCols = 2: ColW = 20: Row = 5
Col(1) = 15: Col(2) = 45: Fg = 0: Fg = 7
CALL Prlist(List$(), ListN, NumInCols, NumOfCols, ColW, Row, Col(), KeyCode, ArrayNum, Fg, Bg)
LOCATE 14, 15: PRINT "KeyCode = "; KeyCode
LOCATE 15, 15: PRINT "ArrayNum = "; ArrayNum
LOCATE 16, 15: PRINT "String Array = "; List$(ArrayNum)
'Example 2:
ListN = 5: NumInCols = 1: NumOfCols = 5: ColW = 13: Row = 1
Col(1) = 1: Col(2) = 18: Col(3) = 34: Col(4) = 49: Col(5) = 64
Fg = 0: Fg = 7
CALL Prlist(List$(), ListN, NumInCols, NumOfCols, ColW, Row, Col(), KeyCode, ArrayNum, Fg, Bg)
DATA Frank A Jones, June N Jones, Terry A Jones, Jeff T Jones, Alfred Jones
DATA Frank A Smith, June N Smith, Terry A Smith, Jeff T Smith, Alfred Smith
'
SUB Prlist (List$(), ListN, NumInCols, NumOfCols, ColW, Row, Col(), KeyCode, ArrayNum, Fg, Bg)
CONST ENTER = 13, ESC = 27, DOWN = -80, HOME = -71
CONST UP = -72, PGUP = -73, PGDN = -81
CONST LEFT = -75, RIGHT = -77, ENDKEY = -79
CONST F1 = -59, F2 = -60, F3 = -61, F4 = -62, F5 = -63
CONST F6 = -64, F7 = -65, F8 = -66, F9 = -67, F10 = -68
TRUE = 1: Findx = 1: LastStartPr = -1
LR = Row: LCol = Col(1): Lx = Findx
IF ArrayNum < 0 THEN
Findx = ABS(ArrayNum)
GOSUB TestFindx
END IF
IF KeyCode = 1 THEN
KeyCode = 3
GOSUB PrintRoutine
KeyCode = 0
EXIT SUB
END IF
IF KeyCode = 2 THEN
Findx = ListN: KeyCode = 3
GOSUB PrintRoutine
KeyCode = 0
EXIT SUB
END IF
GOSUB PrintRoutine
DO
DO
i$ = INKEY$
LOOP UNTIL LEN(i$)
IF LEN(i$) = 1 THEN
KeyC = ASC(i$)
ELSE
KeyC = -ASC(RIGHT$(i$, 1))
END IF
SELECT CASE KeyC
CASE 33 TO 126
FoundIt = 0
FOR x = Findx + 1 TO ListN
S$ = LTRIM$(List$(x))
IF UCASE$(MID$(S$, 1, 1)) = UCASE$(CHR$(KeyC)) THEN
Findx = x
FoundIt = 1
EXIT FOR
END IF
NEXT
IF FoundIt = 0 THEN
FOR x = 1 TO Findx
S$ = LTRIM$(List$(x))
IF UCASE$(MID$(S$, 1, 1)) = UCASE$(CHR$(KeyC)) THEN
Findx = x
EXIT FOR
END IF
NEXT
END IF
CASE ENTER, ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10
KeyCode = ABS(KeyC)
ArrayNum = Findx
EXIT SUB
CASE ENDKEY
Findx = ListN
CASE HOME
Findx = 1
CASE LEFT
Findx = Findx - NumInCols
CASE RIGHT
Findx = Findx + NumInCols
CASE UP
Findx = Findx - 1
CASE DOWN
Findx = Findx + 1
CASE PGUP
Findx = Findx - (NumInCols * NumOfCols)
CASE PGDN
Findx = Findx + (NumInCols * NumOfCols)
END SELECT
GOSUB TestFindx
GOSUB PrintRoutine
LOOP WHILE TRUE
PrintRoutine:
R = Row: ColCnt = 1: Col = Col(ColCnt)
StartPr = ((Findx - 1) \ (NumInCols * NumOfCols)) * (NumInCols * NumOfCols)
IF LastStartPr = StartPr THEN
sw = 1
END IF
LastStartPr = StartPr
FOR xx = 1 TO (NumInCols * NumOfCols)
COLOR Fg, Bg
x = StartPr + xx
IF sw = 0 THEN
IF x < ListN + 1 THEN
IF List$(x) <> "" THEN
LOCATE R, Col: PRINT LEFT$(List$(x) + SPACE$(ColW), ColW);
END IF
ELSE
LOCATE R, Col: PRINT SPACE$(ColW);
END IF
END IF
IF x = Findx AND KeyCode <> 3 THEN
IF sw = 1 THEN
LOCATE LR, LCol: PRINT LEFT$(List$(Lx) + SPACE$(ColW), ColW);
END IF
COLOR Bg, Fg
LOCATE R, Col: PRINT LEFT$(List$(x) + SPACE$(ColW), ColW);
LR = R: LCol = Col: Lx = x
END IF
RowCnt = RowCnt + 1
R = R + 1
IF RowCnt = NumInCols THEN
ColCnt = ColCnt + 1
R = Row
IF ColCnt > NumOfCols THEN
ColCnt = NumOfCols
END IF
Col = Col(ColCnt)
RowCnt = 0
END IF
NEXT
sw = 0: R = Row
RETURN
TestFindx:
IF Findx < 1 THEN
Findx = 1
END IF
IF Findx > ListN THEN
Findx = ListN
END IF
IF KeyC = DOWN AND List$(Findx) = "" THEN
Findx = Findx + 1
GOTO TestFindx
END IF
IF KeyC = UP AND List$(Findx) = "" THEN
Findx = Findx - 1
GOTO TestFindx
END IF
RETURN
END SUB