home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Zodiac Super OZ
/
MEDIADEPOT.ISO
/
FILES
/
13
/
N_B_V203.ZIP
/
MENU-IDX.DMO
< prev
next >
Wrap
Text File
|
1996-07-04
|
8KB
|
187 lines
$if 0
┌──────────────────────────╖ PowerBASIC v3.20
┌──┤ DASoft ╟──────────────────────┬──────────────────╖
│ ├──────────────────────────╢ Copyright 1995 │ DATE: 1995-10-01 ╟─╖
│ │ FILE NAME MENU-IDX.DMO ║ by ╘════════════════─ ║ ║
│ │ ║ Don Schullian, Jr. ║ ║
│ ╘══════════════════════════╝ ║ ║
│ A license is hereby granted to the holder to use this source code in ║ ║
│ any program, commercial or otherwise, without receiving the express ║ ║
│ permission of the copyright holder and without paying any royalties, ║ ║
│ as long as this code is not distributed in any compilable format. ║ ║
│ IE: source code files, PowerBASIC Unit files, and printed listings ║ ║
╘═╤═════════════════════════════════════════════════════════════════════╝ ║
│ .................................... ║
╘═══════════════════════════════════════════════════════════════════════╝
This menu is primarily designed to provide the user a quick and efficient
method of searching long lists of items that are in alphabetical order.
Index lists and the like lend themselves very well here as it usually
only takes 3 or 4 key-strokes to get to the exact entry being sought.
A secondary ability of the function is to be able to "tag" items or groups
of items. This is done by placing a special character at the end of the
elements that have been tagged.
I have used both of these styles for years now in a program that handles
over 8,000 names and 20,000 products and it still only requires an average
of 4 keys to find a particular item. The tagging feature allows the user
to select only a few items to print, preform tasks on, etc. and makes a
program very friendly and very powerful.
Unlike the other two Tmenu FUNCTIONS, this one uses a stationary bar and
moves the entire list up and down. This makes it easier for the user to
maintain eye contact while typing in the search pattern. It also allows
display of items both preceding and following the "center" item which,
in turn, allows the user to quickly scan the whole area. Assuming we
were looking for a "SMITH, JOHN T.". There may be several "SMITH"'s and
maybe even a couple "SMITH, JOHN"'s but by typing in "SMITH" the user
very quickly sees all the Smith's and can then use the arrow keys to
move to the exact one.
There are a few differences here from fTmenuHOT% that are required to
make this menu work correctly. Please review the list below:
I$(0) holds the data for TmenuTYPE + "Menu Title"
I$(1) and on is sorted and in UPPER CASE
the items should NOT be padded with spaces but it will still work
Any NULL items in the array follow the sorted items
The right-most character of the tagged items is CHR$(.HKs)
IF H$ <> "" THEN fHelpLine$ is used to save/restore the screen
.Irows must be an odd number
.Icols must = 1
.Iwide must be set to the correct length of the longest item not
counting the tagging character
or
the length of I$(1) will be used
Several keys (below) are common to both type menus while others only
kick-in when "tagging" is in effect. The <ENTER> key switches operations
depending on the usage.
Note how <F-9> operates: unlike fTmenuHOT% where it turns everything ON
here it only works on whatever the search string matches:
eg: "SMITH" is being searched for when <F-9> is pressed
all items starting with "SMITH" will be tagged
eg: the search string is NULL but "SMITH, JOHN T." is the hot item
all items starting with "S" will be tagged.
<UP><DOWN> move 1 position in the list <─┐
<PgUp><PgDn> move .Irows - 1 in the list <─┤ removes search string
<HOME><END> move to first/last in the list <─┘
<RIGHT><LEFT> add/decrease search string
<BkSp> same as <LEFT>
<DEL> erase search string
<LETTER> add this letter to the search pattern/move to 1st match
<ENTER> if NOT tagging: select item/exit menu
───────────── IF TAGGING ──────────────────────────────────────────────
<ENTER> toggle item ON/OFF note: <SPACE> may be in the index items
<F-10> exit menu
<F-4> un-tag all items
<F-9> tag all items matching current search OR
all items starting with same 1st letter of current item
$endif
$STACK 4096
$STRING 32
$ERROR ALL ON
RANDOMIZE 1234
$INCLUDE "DAS-NB01.INC"
$INCLUDE "DAS-NB02.INC"
$INCLUDE "DAS-NBT1.INC"
$INCLUDE "DAS-NBT3.INC"
LastItem% = 100 ' => 50 please
ScrnBackGrnd? = 112
ExetKey$ = CHR$(027,0) ' <ESC> exits
DIM tM AS TmenuTYPE
tM.Setup = 0 ' let it compute the menu position, etc
tM.Row = 0 ' 1st row ( will center if 0 )
tM.Col = 0 ' 1st column ( will center if 0 )
tM.IWide = 20 ' width of items
tM.IRows = 11 ' N° of items down ( 9 and 11 are best )
tM.ICols = 1 ' always 1
tM.Vert = 1 ' always 1
tM.Wrap = 0 ' NOT USED (always ZERO)
tM.HKs = 4 ' > 0 = Tag
tM.AttrN = 023 ' Normal Item : White/Blue
tM.AttrL = 116 ' Search string : Red/White
tM.AttrB = 113 ' Selection Bar : Blue/White
tM.AttrO = 0 ' NOT USED
tM.Srow = 1 ' turn on TsliderV
tM.Scol = 0 ' computed
tM.Srows = 0 ' computed
tM.Aattr = 30 ' HiYellow/Blue
tM.BrDr = 1 ' Box Border (0 = no border) SEE: TBoxDRAW
tM.Battr = 023 ' Box Color Attribute : White/Blue
tM.Shdo = 1 ' Shadow type SEE: DrawShadow
tM.Sattr = 008 ' Shadow Color Attribute : Grey/Black
tM.Tpos = 4 ' Title Position SEE: MakeTbox
DIM I$(LastItem%)
I$(0) = tM + "INDEX MENU"
RESTORE MENUSSdata
FOR I% = 1 TO LastItem%
READ I$ : IF I$ = "XXENDXX" THEN EXIT FOR
I$(I%) = I$
NEXT
FOR I% = I% TO LastItem%
L% = fRND%( 12, tM.Iwide ) ' variable lengths
I$(I%) = fRNDstr$( 65, 90, L% ) ' random strings
NEXT
MENUSSdata:
DATA "POWER BASIC" , "AARDVARK" , "AARONINSKY, ART"
DATA "SMITH, JOHN A.", "SMITH, JOHN B.", "SMITH, JOHN C."
DATA "SMITH, JOHN D.", "SMITH, JOHN E.", "SMITH, JOHN F."
DATA "XXENDXX"
ARRAY SORT I$(1) FOR LastItem%
IF tM.HKs = 0 THEN
H$ = "<.ENTER/> = SELECT <.TYPE TO SEARCH/>"
ELSE
H$ = "<.ENTER/> = TAG <.F-4/> = ALL OFF <.F-9/> = SEARCH ON <.F-10/> = EXIT"
END IF
HelpLineSETUP 25, 1, 80, 47
DO
TBoxFILL 1, 1, 25, 80, 177, ScrnBackGrnd?
Sn% = fTmenuINDEX% ( I$(), LastItem%, H$, ExetKey$, Sn% )
IF Sn% < 0 THEN EXIT LOOP
IF tM.HKs = 0 THEN
M$ = USING$( " YOU SELECTED N° ### : " + I$(Sn%) + " ", Sn% )
Col? = fCenterPOS%( 1, 80, LEN( M$ ) ) + 3
Tprint 13, Col?, M$, 15
ELSE
Row? = 1
Cols? = tM.Iwide + 1
FOR X% = 1 TO LastItem%
IF fASCIIr%( I$(X%) ) <> tM.HKs THEN ITERATE
TprintCLEAR Row?, 1, Cols?, EXTRACT$( I$(X%), CHR$(tM.HKs) ), 112
INCR Row?, 1
IF Row? = 25 AND X% < ( LastItem% - 1 ) THEN
Tprint Row?, 1, " AND OTHERS... ", 112
EXIT FOR
END IF
NEXT
END IF
DELAY 2
LOOP
' ────────────────────────────────────────────────────────────────────────────
FUNCTION fGetKey% () LOCAL PUBLIC '┌────────────────────────────────────
'│centralize all incoming key presses
WHILE NOT INSTAT : WEND '│rem this line out if used with EVENTs
FUNCTION = CVI(INKEY$+CHR$(0)) '│read next key press
'│
END FUNCTION '└────────────────────────────────────