home *** CD-ROM | disk | FTP | other *** search
- DECLARE FUNCTION strval$ (a%)
- DEFINT A-Z
- '============================================================================
- ' PURPOSE: These are the general purpose routines needed by the other
- ' modules in the user interface .
- '
- ' To create a library and QuickLib containing all routines from
- ' the User Interface follow these steps:
- ' ed PROLIB71 'load PROLIB71 + /L PROASM71.QLB
- ' load PROLIB71 into QBX and make lib
- '============================================================================
-
- '$INCLUDE: 'qbx.bi'
- '$INCLUDE: 'prolib71.bi'
-
- '
- ' msg$(1) = "Yes, go ahead"
- ' msg$(2) = "No, I don't want to "
- '
- ' Ques$ = "(Y/N)" or any prompt
- ' answ$ = "YyNn" accept only (yn)
- '
- ' AskQuestion msg$(), 2, 1,DispPos, black, white, black, white, Ques$, answ$
- '
- ' IF answ$ = "Y" THEN
- '
- '
- SUB AskQuestion (mop$(), numlines, Border, DispPos, FrmFG, FrmBG, GenFG, GenBG, Ques$, ans$)
- check$ = ans$
- maxwidth = LEN(Ques$)
- FOR j = 1 TO numlines
- Trim mop$(j)
- maxwidth = Maximum(maxwidth, LEN(mop$(j)))
- NEXT j
- maxwidth = maxwidth + 4
- maxheight = numlines + 4
- maxheight = maxheight + 2
-
- IF maxwidth > 80 THEN
- EXIT SUB
- END IF
-
- IF maxheight > 24 THEN
- EXIT SUB
- END IF
-
- LeftCol = 80 - maxwidth
- LeftCol = LeftCol / 2
-
- SELECT CASE DispPos
- CASE 0
- TopRow = 1
- CASE 1
- TopRow = (24 - maxheight)
- TopRow = TopRow / 2
- CASE 2
- TopRow = (24 - maxheight)
- CASE ELSE
- EXIT SUB
- END SELECT
-
- CALL GetBackground(TopRow, LeftCol, TopRow + maxheight + 1, LeftCol + maxwidth + 1, aqbuf$)
- CALL DrawBox(TopRow, LeftCol, maxwidth, maxheight, Border, FrmFG, FrmBG, 1, GenFG, GenBG, 1)
-
- FOR j = 1 TO numlines
- Diff = (maxwidth - LEN(mop$(j)))
- IF Diff THEN
- Diff = Diff / 2
- END IF
- TextToPrint$ = mop$(j)
- ROW = j + TopRow + 1
- col = LeftCol + Diff
- CALL pnc(TextToPrint$, ROW, col, GenFG, GenBG)
- NEXT j
-
- ROW = TopRow + numlines + 3
- Diff = (maxwidth - LEN(Ques$))
-
- IF Diff THEN
- Diff = Diff / 2
- END IF
-
- col = LeftCol + Diff
- CALL pnc(Ques$, ROW, col, GenBG, GenFG)
-
- DO
- ans$ = ""
- WHILE ans$ = ""
- ans$ = UCASE$(INKEY$)
- WEND
- LOOP WHILE INSTR(check$, ans$) = 0
-
- CALL PutBackground(TopRow, LeftCol, aqbuf$): aqbuf$ = ""
- END SUB
-
- SUB CapsOff STATIC
- DEF SEG = 0
- POKE &H417, PEEK(&H417) AND &HBF
- DEF SEG
- END SUB
-
- SUB CapsOn STATIC
- DEF SEG = 0
- POKE &H417, PEEK(&H417) OR &H40
- DEF SEG
- END SUB
-
- ' center text on printer
- ' PW = printer with to center text
- '
- SUB CenterPrn (text$, PW%) STATIC
- a% = PW% - LEN(RTRIM$(text$))
- a% = a% / 2
- LPRINT TAB(a%); text$
- END SUB
-
- REM $DYNAMIC
- SUB CenterText (mop$, ROW, fg, bg) STATIC
- c = 80 - LEN(mop$)
- c = c / 2
- pnc mop$, ROW, c, fg, bg
- END SUB
-
- REM $STATIC
- '
- FUNCTION CheckFunction (ch)
- IF ch > 58 AND ch < 69 THEN
- CheckFunction = ch - 58
- END IF
- IF ch > 83 AND ch < 114 THEN
- CheckFunction = ch - 73
- END IF
- END FUNCTION
-
- REM $DYNAMIC
- FUNCTION CheckPrinter%
- ' returns zero if printer not ready
- DIM printer$(2)
- DEF SEG = &H40
- prtrbase% = PEEK(9) * 256 + PEEK(8) + 1
-
- pcode% = INP(prtrbase%)
-
- DEF SEG
-
- SELECT CASE pcode%
-
- CASE 71
- printer$(1) = "Printer Off Line"
- CheckPrinter% = 0
- CASE 87
- printer$(1) = "Printer Off Line"
- CheckPrinter% = 0
-
- CASE 119
- printer$(1) = "Printer Out of Paper"
- CheckPrinter% = 0
- CASE 127
- printer$(1) = "Printer Not Connected"
- CheckPrinter% = 0
- CASE 135
- printer$(1) = "Printer Turned Off"
- CheckPrinter% = 0
- CASE 191
- printer$(1) = "Printer Not Connected"
- CheckPrinter% = 0
-
- CASE 223
- CheckPrinter% = 1
- EXIT FUNCTION
- CASE 247
- printer$(1) = "Printer Turned Off"
- CheckPrinter% = 0
-
- CASE ELSE
- CheckPrinter% = pcode%
-
- printer$(1) = "Printer Code: " + STR$(pcode%)
- printer$(2) = "Correct and Press anykey"
-
- Message printer$(), 2, 2, BLACK, WHITE, BLACK, WHITE
-
- END SELECT
- printer$(2) = "Correct and Press anykey"
-
- Message printer$(), 2, 2, BLACK, WHITE, BLACK, WHITE
-
- END FUNCTION
-
- REM $STATIC
- '
- SUB DialogBox (Ques$(), Before, After, LENGTH, FrmFG, FrmBG, GenFG, GenBG, DispPos, Answer$, format$, Ek)
-
- boxheight = Before + After
- height = boxheight
- height = height + 5
-
- IF height > 25 THEN
- EXIT SUB
- END IF
-
- IF LENGTH < 1 THEN
- EXIT SUB
- END IF
-
- SELECT CASE DispPos
- CASE 0
- begin = 1
- shadow = 1
- CASE 1
- begin = (25 - height) / 2
- shadow = 1
- CASE 2
- begin = (25 - height) + 1
- shadow = 0
- CASE ELSE
- EXIT SUB
- END SELECT
- textwidth = LENGTH
-
- FOR j = 1 TO boxheight
- Trim Ques$(j)
- IF LEN(Ques$(j)) > textwidth THEN
- textwidth = LEN(Ques$(j))
- END IF
- NEXT j
- BoxWidth = textwidth + 4
- LeftCol = (80 - BoxWidth) / 2
- Wid = BoxWidth
- FrameType = 1
- Fill = 1
-
- GetBackground begin, LeftCol, begin + height + 2, LeftCol + Wid + 2, dbbuf$
- DrawBox begin, LeftCol, Wid, height, FrameType, FrmFG, FrmBG, Fill, GenFG, GenBG, shadow
-
- FOR j = 1 TO Before
- mop$ = Ques$(j)
- Trim mop$
- c = Wid - LEN(mop$)
- c = c / 2
- pnc mop$, begin + j, LeftCol + c, GenFG, GenBG
- NEXT j
- FOR j = 1 TO After
- mop$ = Ques$(j + Before)
- Trim mop$
- c = Wid - LEN(mop$)
- c = c / 2
- pnc mop$, begin + Before + 3 + j, LeftCol + c, GenFG, GenBG
- NEXT j
-
- Istart = (80 - LENGTH) / 2
- DrawBox begin + Before + 1, Istart - 1, LENGTH + 2, 3, 1, FrmFG, FrmBG, 0, GenFG, GenBG, 0
- xc = LeftCol + 2
- yc = begin + Before + 2
- LOCATE yc, Istart
-
- IF format$ = "" THEN
- format$ = STRING$(LENGTH, "#")
- Answer$ = FES(0, GenFG, GenBG, Answer$, format$, 1, Ek, 0, 0, 0, 0, 1, 1, 1, 0)
- ELSEIF INSTR(format$, ".") THEN
- Answer$ = FEN(0, GenFG, GenBG, Answer$, format$, Ek, 0, 0, 0, 0, 1, 1, 1)
- ELSE
- Answer$ = FES(0, GenFG, GenBG, Answer$, format$, 1, Ek, 0, 0, 0, 0, 1, 1, 1, 0)
- END IF
-
- PutBackground begin, LeftCol, dbbuf$: dbbuf$ = ""
- END SUB
-
- SUB dialogtwo (dialog$(), first$, lenfirst, second$, lensecond) STATIC
-
- d% = lenfirst
- IF d% > lensecond THEN
- d% = lensecond
- END IF
- FOR j% = 1 TO 4
- k% = LEN(dialog$(j%))
- IF k% > d% THEN d% = k%
- NEXT j%
- w% = d% + 6
-
- lmarg% = (80 - w%) / 2
- tmarg% = 7
- rmarg% = lmarg% + w% - 1
- bmarg% = 18
-
- CALL GetBackground(tmarg%, lmarg%, bmarg%, rmarg%, dl2$)
- CALL drawwind(tmarg%, lmarg%, bmarg%, rmarg%, 1, 1)
- CALL Colorwind(tmarg%, lmarg%, bmarg%, rmarg%, 32, 1, BLACK, WHITE)
-
- lmarg% = lmarg% + 4
-
- CALL pnc(dialog$(1), tmarg% + 1, lmarg%, BLACK, WHITE)
- CALL pnc(dialog$(2), tmarg% + 5, lmarg%, BLACK, WHITE)
- CALL pnc(dialog$(3), tmarg% + 9, lmarg%, BLACK, WHITE)
- CALL pnc(dialog$(4), tmarg% + 10, lmarg%, BLACK, WHITE)
-
- ipy1% = tmarg% + 2
- ipy2% = tmarg% + 6
-
- IF lenfirst THEN
- CALL drawwind(ipy1%, lmarg%, ipy1% + 2, lenfirst + lmarg% + 1, 1, 0)
- END IF
-
- IF lensecond THEN
- CALL drawwind(ipy2%, lmarg%, ipy2% + 2, lensecond + lmarg% + 1, 1, 0)
-
- END IF
-
- IF lenfirst THEN
- LOCATE ipy1% + 1, lmarg% + 1
- format$ = STRING$(lenfirst, "#")
- first$ = FES(0, BLACK, WHITE, second$, format$, 0, Ek%, 0, 0, 0, 0, 1, 1, 1, 0)
-
- END IF
-
- IF lensecond THEN
- LOCATE ipy2% + 1, lmarg% + 1
- format$ = STRING$(lensecond, "#")
- second$ = FES(0, BLACK, WHITE, second$, format$, 0, Ek%, 0, 0, 0, 0, 1, 1, 1, 0)
-
- END IF
-
- CALL PutBackground(tmarg%, lmarg% - 4, dl2$): dl2$ = ""
- LOCATE , , 0
-
- END SUB
-
- REM $DYNAMIC
- '
- SUB DoMoney (amount@, alpha1$, alpha2$)
-
- money$ = ""
-
- amount$ = userNformat$(STR$(amount@), "999999.99")
- ones$ = " ONE TWO THREEFOUR FIVE SIX SEVENEIGHTNINE "
- teen$ = "TEN ELEVEN TWELVE THIRTEENFOURTEEN FIFTEEN SIXTEEN SEVENTEENEIGHTEEN NINETEEN "
- tens$ = "TWENTY THIRTY FORTY FIFTY SIXTY SEVENTYEIGHTY NINETY"
-
- 'hundreds of thousands
-
- IF LEFT$(amount$, 1) > " " THEN
- money$ = RTRIM$(MID$(ones$, VAL(LEFT$(amount$, 1)) * 5 + 1, 5)) + " HUNDRED "
- END IF
-
- ' tens of thousands
-
- IF MID$(amount$, 2, 1) > "1" THEN
- money$ = money$ + RTRIM$(MID$(tens$, VAL(MID$(amount$, 2, 1)) * 7 - 13, 7))
- IF MID$(amount$, 3, 1) > "0" THEN
- money$ = money$ + "-" + RTRIM$(MID$(ones$, VAL(MID$(amount$, 3, 1)) * 5 + 1, 5))
- END IF
- money$ = money$ + " THOUSAND "
- ELSEIF MID$(amount$, 2, 1) = "1" THEN
- money$ = money$ + RTRIM$(MID$(teen$, VAL(MID$(amount$, 3, 1)) * 9 + 1, 9)) + " THOUSAND "
- ELSEIF MID$(amount$, 2, 2) = "00" THEN
- money$ = money$ + "THOUSAND "
- ELSEIF MID$(amount$, 3, 1) > " " THEN
- money$ = money$ + RTRIM$(MID$(ones$, VAL(MID$(amount$, 3, 1)) * 5 + 1, 5)) + " THOUSAND "
- END IF
-
- ' hundreds
-
- IF MID$(amount$, 4, 1) > "0" THEN
- money$ = money$ + RTRIM$(MID$(ones$, VAL(MID$(amount$, 4, 1)) * 5 + 1, 5)) + " HUNDRED "
- END IF
-
- ' tens and ones
-
- IF MID$(amount$, 5, 1) > "1" THEN
- money$ = money$ + RTRIM$(MID$(tens$, VAL(MID$(amount$, 5, 1)) * 7 - 13, 7))
- IF MID$(amount$, 6, 1) > "0" THEN
- money$ = money$ + "-" + RTRIM$(MID$(ones$, VAL(MID$(amount$, 6, 1)) * 5 + 1, 5))
- END IF
- ELSEIF MID$(amount$, 5, 1) = "1" THEN
- money$ = money$ + RTRIM$(MID$(teen$, VAL(MID$(amount$, 6, 1)) * 9 + 1, 9))
- ELSE
- IF VAL(MID$(amount$, 1, 6)) = 0 THEN
- money$ = "ZERO"
- END IF
- money$ = money$ + RTRIM$(MID$(ones$, VAL(MID$(amount$, 6, 1)) * 5 + 1, 5))
- END IF
-
- 'do decimal places
-
- cents$ = RIGHT$(amount$, 2)
- money$ = RTRIM$(money$) + " AND " + cents$ + "/100" ' DOLLARS"
- LENGTH = LEN(money$)
-
- ' if length is greater than 75, the words will have to be
- ' split so that it will fit on the check
-
- IF LENGTH > 75 THEN
- counter = 74
- DO WHILE INSTR(counter, money$, " - ")
- counter = counter - 1
- LOOP
- ' divide the string into two parts
- alpha1$ = LEFT$(money$, counter) ' + LEFT$(STOREAGE$, 75 - counter)
- alpha2$ = MID$(money$, counter + 1, LENGTH - counter)
- Trim alpha1$
- Trim alpha2$
- ELSE
- ' word is less than or equal to 75 characters
- alpha1$ = money$
- Trim alpha1$
- END IF
- END SUB
-
- REM $STATIC
- SUB DrawBox (TopRow, LeftCol, Wid, height, FrameType, FrmFgd, FrmBgd, Fill, FillFgd, FillBgd, shadow) STATIC
- IF Wid < 2 THEN
- EXIT SUB
- END IF
- IF height < 2 THEN
- EXIT SUB
- END IF
- botrow = TopRow + height - 1
- rightcol = LeftCol + Wid - 1
- 'draw frame
- CALL drawwind(TopRow, LeftCol, botrow, rightcol, FrameType, 0)
- 'color frame
- CALL Colorwind(TopRow, LeftCol, botrow, rightcol, 0, 1, FrmFgd, FrmBgd)
- IF shadow THEN
- ' do RIGHTK shadow
- CALL Colorwind(TopRow + 1, LeftCol + Wid, botrow + 1, LeftCol + Wid + 1, 0, 1, 7, 0)
- ' do bottom shadow
- CALL Colorwind(botrow + 1, LeftCol + 1, botrow + 1, LeftCol + Wid + 1, 0, 1, 7, 0)
- END IF
- SELECT CASE Fill
- CASE 1
- body$ = " "
- CASE 2
- body$ = "▓"
- CASE 3
- body$ = "█"
- CASE 4
- body$ = "░"
- CASE 5
- body$ = "▒"
- CASE ELSE
- body$ = " "
- END SELECT
-
- IF Fill <> 0 THEN
- CALL Colorwind(TopRow + 1, LeftCol + 1, botrow - 1, LeftCol + Wid - 2, ASC(body$), 0, FillFgd, FillBgd)
- END IF
-
- END SUB
-
- REM $DYNAMIC
- SUB DspEquipment
- romdate$ = "00/00/00"
-
- DIM disp$(15)
-
- CALL GetRomDate(romdate$)
- CALL GetRam(ram%, EXTram%, EXPram%)
- printers% = GetNumLPT
- rs232% = GetNumCom
- floppies% = GetNumFlop
- gameport% = GetNumGames
- disks% = GetNumHard
-
- SELECT CASE VIDEOcheck
- CASE 1
- vid$ = "MDA"
- CASE 2
- vid$ = "HCG"
- CASE 3
- vid$ = "CGA"
- CASE 4
- vid$ = "EGA"
- CASE 5
- vid$ = "VGA Color"
- CASE 6
- vid$ = "VGA Mono"
- CASE 7
- vid$ = "MODEL 30 Mono"
- CASE 8
- vid$ = "MODEL 30 Color"
- CASE ELSE
- vid$ = "UnKnown"
- END SELECT
-
- SELECT CASE CPUcheck
- CASE 1
- cpu$ = "8086/88"
- CASE 2
- cpu$ = "80286"
- CASE 3
- cpu$ = "386/486"
- CASE ELSE
- cpu$ = "UnKnown"
- END SELECT
- disp$(1) = "CPU type.................: " + cpu$
- disp$(2) = "Video type...............: " + vid$
- disp$(3) = "Rom Bios Date............: " + romdate$
- disp$(4) = "Amount of DOS RAM........: " + userNformat$(STR$(ram%), "9999999") + "K"
- disp$(5) = "Amount of EXT RAM........: " + userNformat$(STR$(EXTram%), "9999999") + "K"
- disp$(6) = "Amount of EXP RAM........: " + userNformat$(STR$(EXPram% * 16), "9999999") + "K"
- disp$(7) = "Number of Printer Ports..: " + userNformat$(STR$(printers%), "9999999")
- disp$(8) = "Number of RS232..........: " + userNformat$(STR$(rs232%), "9999999")
- disp$(9) = "Number of Floppies.......: " + userNformat$(STR$(floppies%), "9999999")
- disp$(10) = "Number of Hard drives....: " + userNformat$(STR$(disks%), "9999999")
- disp$(11) = "Number of Game ports.....: " + userNformat$(STR$(gameport%), "9999999")
- disp$(12) = ""
- disp$(13) = "Press any key to continue"
-
- lines = 13
- Border = 2
-
- FrmFG = BLACK
- FrmBG = WHITE
- GenFG = BLACK
- GenBG = WHITE
- maxwidth = 0
-
- El = UBOUND(disp$, 1)
-
- IF lines > El THEN
- EXIT SUB
- END IF
- FOR j = 1 TO lines
- Trim disp$(j)
- maxwidth = Maximum(maxwidth, LEN(disp$(j)))
- NEXT j
- maxwidth = maxwidth + 5
- maxheight = lines + 4
-
- IF maxwidth > 80 THEN
- EXIT SUB
- END IF
-
- IF maxheight > 24 THEN
- EXIT SUB
- END IF
-
- TopRow = 24 - maxheight
- TopRow = TopRow / 2
- LeftCol = 80 - maxwidth
- LeftCol = LeftCol / 2
-
- GetBackground TopRow, LeftCol, TopRow + maxheight + 1, LeftCol + maxwidth + 1, msbuf$
- DrawBox TopRow, LeftCol, maxwidth, maxheight, Border, FrmFG, FrmBG, 1, GenFG, GenBG, 1
-
- FOR j = 1 TO lines
- Diff = (maxwidth - LEN(disp$(j)))
- IF Diff THEN
- Diff = Diff / 2
- END IF
- TextToPrint$ = disp$(j)
- ROW = j + TopRow + 1
- col = LeftCol + 2'+ Diff
- pnc TextToPrint$, ROW, col, GenFG, GenBG
- NEXT j
- DO
- key$ = INKEY$
- LOOP UNTIL key$ <> ""
- PutBackground TopRow, LeftCol, msbuf$: msbuf$ = ""
-
-
- END SUB
-
- REM $STATIC
- '
- 'DATE: 05/30/90
- 'DATE: 10/03/91
- ' numeric formats allow higest
- ' value of format position.
- '
- ' format$ = "99999.99" decimal ( any decimal position)
- ' format$ = "99" numbers only < (99 max) each digit = to max value
- ' format$ = "19" (19) is max value
- '
- ' use basic print using "####.##";VAL(instring$) for decimal numbers
- ' or integer. decimal pos and length optional
- '
- ' USE LOCATE ROW,COLUMN
- '
- ' maybe passed by parameters if you like to add to parms
- '
- ' column = Column pos to start printing
- ' Row = Row to start printing
- '
- ' set editforeground color before call
- ' set editbackgroung color before call
- '
- ' ExitCode = VALUE EXIT 1 TO 7
- '
- ' set flags to enable to exit on key
- '
- ' UPflag = True ,exitcode = 1
- ' PGUPflag = True ,exitcode = 2
- ' DNflag = True ,exitcode = 3
- ' PGDNflag = True ,exitcode = 4
- ' RETflag = True ,exitcode = 5
- ' TABflag = True ,exitcode = 6
- ' ESCflag = True ,exitcode = 7
- '
- ' ESC key restores field if True or False
- '
- ' sample how to handle exitcode after input routine (see program).
- '
- ' SELECT CASE ExitCode%
- '
- ' CASE 1 'what to do if uparrow key exit
- ' could be
- ' GOTO previous entry
- '
- ' CASE 2 'what to do if pageup key exit
- '
- ' CASE 3 'what to do if downarrow key exit
- ' could be
- ' GOTO next entry
- ' CASE 4 'what to do if pagedown key exit
- '
- ' CASE 5 'what to do if enter key exit
- ' could be accept entry
- ' CASE 6 'what to do if tab key exit
- ' 'could be return to menu
- '
- ' END SELECT
- '
- FUNCTION FEN$ (SB, EFG, EBG, work$, format$, Exitcode, UPflag, PGUPflag, DNflag, PGDNflag, RETflag, TABflag, escflag)
-
-
- STATIC curpos
- ROW = CSRLIN
- col = POS(0)
- DIM Hlp$(9)
- firsttime = 1
- LENGTH = LEN(format$)
- IF SB = TRUE THEN
- GetBackground ROW, col, ROW, col + LENGTH, ed$
- END IF
-
- SELECT CASE LEN(work$)
- CASE IS > LENGTH
- work$ = RIGHT$(work$, LENGTH)
- CASE IS < LENGTH
- work$ = STRING$(LENGTH - LEN(work$) - 1, " ") + work$
- END SELECT
-
- IF INSTR(format$, ".") THEN
- decflag = 1
- IF INSTR(work$, ".") THEN
- FormatDEC (work$), bforeDEC, aftDEC
- FormatDEC (format$), beforeDEC, afterdec
- work$ = RemoveCHAR$((work$), ".")
- IF afterdec > aftDEC THEN
- work$ = work$ + STRING$(afterdec - (aftDEC - 1), "0")
- END IF
- IF afterdec < aftDEC THEN
- work$ = STRING$(aftDEC - (afterdec - 1), " ") + LEFT$(work$, beforeDEC + (afterdec - 1))
- END IF
- ELSE
- FormatDEC format$, beforeDEC, afterdec
- work$ = work$ + STRING$(afterdec + 1, "0")
- END IF
- ELSE
- FormatDEC (work$), beforeDEC, afterdec
- work$ = LEFT$(work$, beforeDEC)
- afterdec = 0
- work$ = STRING$(LENGTH - LEN(work$), " ") + work$
- decflag = 0
- END IF
- SELECT CASE LEN(work$)
- CASE IS > LENGTH
- work$ = RIGHT$(work$, LENGTH)
- CASE IS < LENGTH
- IF decflag THEN
- work$ = STRING$(LENGTH - LEN(work$) - 1, " ") + work$
- ELSE
- work$ = STRING$(LENGTH - LEN(work$), " ") + work$
- END IF
- END SELECT
- temp$ = work$
- work$ = STRING$(LENGTH, " ")
- k = 1
- FOR j = 1 TO LENGTH
- Character$ = MID$(format$, j, 1)
- IF INSTR(".", Character$) THEN
- MID$(work$, j, 1) = Character$
- ELSE
- char$ = MID$(temp$, k, 1)
- MID$(work$, j, 1) = char$
- k = k + 1
- END IF
- NEXT j
- org$ = work$
- curpos = 1
- Exitcode = 0
- 'COLOR efg, ebg
- LOCATE ROW, col
- 'PRINT work$;
- pnc work$, ROW, col, EFG, EBG
-
- DO
- SELECT CASE curpos
- CASE IS > LENGTH
- curpos = LENGTH
- CASE IS < 1
- curpos = 1
- END SELECT
- LOCATE ROW, col
- 'PRINT work$;
- pnc work$, ROW, col, EFG, EBG
-
- LOCATE ROW, col + LENGTH - 1, 1, 7, 7
- Choice$ = ""
- WHILE Choice$ = ""
- Choice$ = INKEY$
- WEND
- LOCATE , , 0
- IF LEN(Choice$) = 1 THEN
- special$ = MID$(format$, curpos, 1)
- keychoice = ASC(Choice$)
- SELECT CASE keychoice
- CASE ENTER
- IF RETflag = TRUE THEN
- Exitcode = 5
- EXIT DO
- END IF
- CASE TABKEY
- IF TABflag = TRUE THEN
- Exitcode = 6
- EXIT DO
- END IF
- CASE ESC
- work$ = org$
- curpos = 1
- IF escflag = TRUE THEN
- Exitcode = 7
- EXIT DO
- END IF
- CASE CTRLE
- work$ = ""
- IF LEN(work$) = 0 THEN
- IF afterdec > 0 THEN
- work$ = STRING$(afterdec, "0")
- IF LEN(work$) < LENGTH THEN
- IF decflag THEN
- work$ = STRING$(LENGTH - LEN(work$) - 1, " ") + work$
- ELSE
- work$ = STRING$(LENGTH - LEN(work$), " ") + work$
- END IF
- work$ = userSformat$(work$, format$)
- END IF
- ELSE
- work$ = ""
- IF LEN(work$) < LENGTH THEN
- IF decflag THEN
- work$ = STRING$(LENGTH - LEN(work$) - 1, " ") + work$
- ELSE
- work$ = STRING$(LENGTH - LEN(work$), " ") + work$
- END IF
- work$ = userSformat$(work$, format$)
- END IF
- END IF
- END IF
- END SELECT
- SELECT CASE special$
- CASE "0" TO "9"
- IF Choice$ <= special$ THEN
- keychoice = ASC(Choice$)
- ELSE
- keychoice = 0
- END IF
- END SELECT
- SELECT CASE Choice$
- CASE "-"
- temp$ = work$
- work$ = ""
- IF LEN(work$) = 0 THEN
- IF afterdec > 0 THEN
- work$ = LTRIM$(RTRIM$(Choice$)) + STRING$(afterdec, "0")
- IF LEN(work$) < LENGTH THEN
- IF decflag THEN
- work$ = STRING$(LENGTH - LEN(work$) - 1, " ") + work$
- ELSE
- work$ = STRING$(LENGTH - LEN(work$), " ") + work$
- END IF
- work$ = userSformat$(work$, format$)
- END IF
- ELSE
- work$ = LTRIM$(RTRIM$(Choice$))
- IF LEN(work$) < LENGTH THEN
- IF decflag THEN
- work$ = STRING$(LENGTH - LEN(work$) - 1, " ") + work$
- ELSE
- work$ = STRING$(LENGTH - LEN(work$), " ") + work$
- END IF
- work$ = userSformat$(work$, format$)
- END IF
- END IF
- END IF
- END SELECT
- SELECT CASE CHR$(keychoice)
- CASE "0" TO "9"
- FOR j = 1 TO LENGTH
- Character$ = MID$(format$, j, 1)
- IF INSTR(".", Character$) THEN
- MID$(work$, j, 1) = CHR$(255)
- cursor = cursor + 1
- END IF
- NEXT j
- work$ = RemoveCHAR$(work$, CHR$(255))
- IF firsttime = 1 THEN
- work$ = STRING$(afterdec, "0") + LTRIM$(RTRIM$(Choice$))
- firsttime = 0
- ELSE
- work$ = LTRIM$(RTRIM$(work$)) + LTRIM$(RTRIM$(Choice$))
- END IF
- IF afterdec > 0 THEN
- IF LEN(work$) >= afterdec THEN
- IF LEFT$(work$, 1) = "0" THEN
- work$ = RIGHT$(work$, LEN(work$) - 1)
- END IF
- END IF
- END IF
- IF afterdec > 0 THEN
- IF MID$(work$, 1, 1) = "-" THEN
- IF LEN(work$) > afterdec + 1 THEN
- IF MID$(work$, 2, 1) = "0" THEN
- work$ = "-" + RIGHT$(work$, LEN(work$) - 2)
- END IF
- END IF
- END IF
- END IF
- IF LEN(work$) < LENGTH THEN
- IF decflag THEN
- work$ = STRING$(LENGTH - LEN(work$) - 1, " ") + work$
- ELSE
- work$ = STRING$(LENGTH - LEN(work$), " ") + work$
- END IF
- END IF
- work$ = userSformat$(work$, format$)
- curpos = curpos + 1
- END SELECT
- ELSE
- keychoice = ASC(MID$(Choice$, 2))
- SELECT CASE keychoice
- CASE DELETEK
- FOR j = 1 TO LENGTH
- Character$ = MID$(format$, j, 1)
- IF INSTR(".", Character$) THEN
- MID$(work$, j, 1) = CHR$(255)
- ELSE
- END IF
- NEXT j
- work$ = RemoveCHAR$(work$, CHR$(255))
- work$ = LTRIM$(RTRIM$(work$))
- IF afterdec > 0 THEN
- IF LEN(work$) <= afterdec THEN
- work$ = "0" + work$
- END IF
- END IF
- IF LEN(work$) THEN
- work$ = LEFT$(work$, LEN(work$) - 1)
- IF decflag THEN
- work$ = STRING$(LENGTH - LEN(work$) - 1, " ") + work$
- ELSE
- work$ = STRING$(LENGTH - LEN(work$), " ") + work$
- END IF
- END IF
- work$ = userSformat$((work$), format$)
- curpos = curpos - 1
- CASE F1
- GetBackground 1, 1, 25, 80, hpbuf$
- Hlp$(1) = "- NUMERIC EDIT HELP -"
- Hlp$(2) = " " + CHR$(255)
- Hlp$(3) = "ESC - restores edit field. " + CHR$(255)
- Hlp$(4) = "ENTER - accepts entry and exits Edit. " + CHR$(255)
- Hlp$(5) = "CTRL E - erases edit field. " + CHR$(255)
- Hlp$(6) = "DELETE - deletes char under cursor and shifts right." + CHR$(255)
- Hlp$(7) = "ANY non edit key erases field if first time entry. " + CHR$(255)
- Hlp$(8) = " " + CHR$(255)
- Hlp$(9) = "Press any key to continue"
- Message Hlp$(), 9, 1, WHITE + 8, RED, WHITE + 8, RED
- 'COLOR efg, ebg
- PutBackground 1, 1, hpbuf$: hpbuf$ = ""
- CASE UPK
- IF UPflag = TRUE THEN
- Exitcode = 1
- EXIT DO
- END IF
- CASE PGUP
- IF PGUPflag = TRUE THEN
- Exitcode = 2
- EXIT DO
- END IF
- CASE PGDN
- IF PGDNflag = TRUE THEN
- Exitcode = 4
- EXIT DO
- END IF
- CASE DOWNK
- IF DNflag = TRUE THEN
- Exitcode = 3
- EXIT DO
- END IF
- CASE ELSE
- END SELECT
- END IF
- firsttime = 0
- LOOP WHILE Exitcode = 0
- 'COLOR ebg, efg
- LOCATE ROW, col, CURSOROFF
- 'PRINT work$;
- pnc work$, ROW, col, EBG, EFG
-
- FOR j = 1 TO LENGTH
- Character$ = MID$(format$, j, 1)
- char$ = MID$(work$, j, 1)
- IF INSTR(".", Character$) THEN
- ELSE
- IF char$ = CHR$(255) THEN
- ELSE
- tmp$ = tmp$ + char$
- END IF
- END IF
- NEXT j
- 'COLOR ebg, efg
- tmp$ = RTRIM$(LTRIM$(tmp$))
- IF LEN(tmp$) - 1 < afterdec THEN
- IF LEFT$(tmp$, 1) = "-" THEN
- tmp$ = "-" + STRING$(afterdec - LEN(tmp$) + 1, "0") + RIGHT$(tmp$, LEN(tmp$) - 1)
- END IF
- END IF
- IF LEN(tmp$) < 2 THEN
- tmp$ = "0" + tmp$
- END IF
- IF decflag THEN
- rwork$ = RIGHT$(tmp$, afterdec)
- lwork$ = LEFT$(tmp$, LEN(tmp$) - LEN(rwork$))
- work$ = lwork$ + "." + rwork$
- END IF
- FEN$ = LTRIM$(RTRIM$(work$))
-
- IF SB = TRUE THEN
- PutBackground ROW, col, ed$: ed$ = ""
- END IF
-
- END FUNCTION
-
- 'DATE: 05/30/90
- 'DATE: 07/14/90
- 'DATE: 010/03/91
- ' RAYMOND E DIXON
- ' 11660 VC JOHNSON RD
- ' Jacksonville, Fl 32218
- ' (904) 765-4048
- '
- ' IF ANYONE MAKES ANY INPROVEMENTS I WOULD LIKE YOU TO RENAME THIS SUB
- ' TO A NEW NAME. AND IF YOU WOULD SEND ME A COPY.
- '
- ' formated input routine with user format
- '
- ' assign values before calling routine
- '
- ' work$ ="" or string to edit
- '
- ' numeric formats allow higest
- ' value of format position.
- '
- ' format$ = "99" numbers only < (99 max) each digit = to max value
- ' format$ = "19" (19) is max value
- ' format$ = "999-99-9999" SS number
- ' format$ = "999-9999" 7 digit phone
- ' format$ = "(999) 999-9999" 10 digit phone
- ' format$ = "19/39/99" date format
- ' format$ = "########" alphanumeric set for 8 characters (maybe more or less)
- ' format$ = "@@@@@@@@" alpha only same as above
- ' format$ = "Y/N:*" force YN answer.
- ' format$ = "M/F:|" force MF answer.
- ' format$ = "~" 'force enter key for prompts or other exit key.
- ' format$ = may be any format you can create in a basic string
- ' even you can include the Prompt if you like.
- '
- ' format$ = "Test Data: 99" 'this format will print
- ' Test Data: your value passed
- ' in the the length of 2
- ' Seting numbers 1 to 99.
- '
- ' USE LOCATE ROW,COLUMN
- '
- ' maybe passed by parameters if you like to add to parms
- '
- ' column = Column pos to start printing
- ' Row = Row to start printing
- '
- ' set foreground color before call
- '
- ' set backgroung color before call
- '
- ' ExitCode = VALUE EXIT 1 TO 9
- '
- ' set flags to enable to exit on key
- ' SB = True ,saves background (text under edit field)
- '
- ' UPflag = True ,exitcode = 1
- ' PGUPflag = True ,exitcode = 2
- ' DNflag = True ,exitcode = 3
- ' PGDNflag = True ,exitcode = 4
- ' RETflag = True ,exitcode = 5
- ' TABflag = True ,exitcode = 6
- ' ESCflag = True ,exitcode = 7
- ' F10flag = true ,exitcode = 9
- ' ESC key restores field if True or False
- '
- ' force case if set.
- ' caseflag = 0 any case
- ' = 1 for upper
- ' = 2 for lower
- '
- ' sample how to handle exitcode after input routine (see program).
- '
- ' SELECT CASE ExitCode%
- '
- ' CASE 1 'what to do if uparrow key exit
- ' could be
- ' GOTO previous entry
- '
- ' CASE 2 'what to do if pageup key exit
- '
- ' CASE 3 'what to do if downarrow key exit
- ' could be
- ' GOTO next entry
- ' CASE 4 'what to do if pagedown key exit
- '
- ' CASE 5 'what to do if enter key exit
- ' could be accept entry
- ' CASE 6 'what to do if tab key exit
- ' 'could be return to menu
- '
- ' END SELECT
- '
- FUNCTION FES$ (SB, EFG, EBG, work$, format$, caseflag, Exitcode, UPflag, PGUPflag, DNflag, PGDNflag, RETflag, TABflag, escflag, F10flag)
-
- STATIC insertmode, curpos
- DIM Hlp$(10)
- ROW = CSRLIN
- col = POS(0)
- firsttime = 1
- LENGTH = LEN(format$)
-
- IF SB = TRUE THEN
- GetBackground ROW, col, ROW, col + LENGTH, ed$
- END IF
-
- FOR j = 1 TO LENGTH
- FChr$ = MID$(format$, j, 1)
- SELECT CASE FChr$
- CASE "~", "@", "0" TO "9", "#", "*", "|"
- CASE ELSE
- formatVALUES$ = formatVALUES$ + FChr$
- END SELECT
- NEXT j
- insertmode = 0
- SELECT CASE LEN(work$)
- CASE IS > LENGTH
- work$ = MID$(work$, 1, LENGTH)
- CASE IS < LENGTH
- work$ = work$ + STRING$(LENGTH - LEN(work$), SPACE)
- END SELECT
- temp$ = work$
- work$ = STRING$(LENGTH, " ")
- k = 1
- FOR j = 1 TO LENGTH
- Character$ = MID$(format$, j, 1)
- IF INSTR(formatVALUES$, Character$) THEN
- MID$(work$, j, 1) = Character$
- ELSE
- char$ = MID$(temp$, k, 1)
- MID$(work$, j, 1) = char$
- k = k + 1
- END IF
- NEXT j
- org$ = work$
- curpos = 1
- Exitcode = 0
- 'COLOR efg, ebg
- LOCATE ROW, col
- 'PRINT work$;
- pnc work$, ROW, col, EFG, EBG
-
- DO
- DO
- IF INSTR(formatVALUES$, MID$(format$, curpos, 1)) THEN
- curpos = curpos + 1
- ELSE
- EXIT DO
- END IF
- IF curpos > LENGTH THEN
- curpos = LENGTH
- DO
- IF INSTR(formatVALUES$, MID$(format$, curpos, 1)) THEN
- curpos = curpos - 1
- ELSE
- EXIT DO
- END IF
- LOOP
- END IF
- LOOP
- SELECT CASE curpos
- CASE IS > LENGTH
- curpos = LENGTH
- CASE IS < 1
- curpos = 1
- END SELECT
- LOCATE ROW, col
- 'PRINT work$;
- pnc work$, ROW, col, EFG, EBG
-
- IF insertmode = TRUE THEN
- LOCATE ROW, col + curpos - 1, 1, 0, 15
- ELSE
- LOCATE ROW, col + curpos - 1, 1, 7, 7
- END IF
- IF INSTR(format$, "~") THEN
- LOCATE ROW, col + curpos - 1, 0, 7, 7
- END IF
- Choice$ = ""
- WHILE Choice$ = ""
- Choice$ = INKEY$
- WEND
- LOCATE , , 0
- IF LEN(Choice$) = 1 THEN
- special$ = MID$(format$, curpos, 1)
- keychoice = ASC(Choice$)
- SELECT CASE keychoice
- CASE ENTER
- IF RETflag = TRUE THEN
- Exitcode = 5
- EXIT DO
- END IF
- CASE TABKEY
- IF TABflag = TRUE THEN
- Exitcode = 6
- EXIT DO
- END IF
- CASE CTRLE
- work$ = STRING$(LENGTH, " ")
- temp$ = STRING$(LENGTH, " ")
- k = 1
- FOR j = 1 TO LENGTH
- Character$ = MID$(format$, j, 1)
- IF INSTR(formatVALUES$, Character$) THEN
- MID$(work$, j, 1) = Character$
- ELSE
- char$ = MID$(temp$, k, 1)
- MID$(work$, j, 1) = char$
- k = k + 1
- END IF
- NEXT j
- curpos = 1
- CASE ESC
- work$ = org$
- curpos = 1
- IF escflag = TRUE THEN
- Exitcode = 7
- EXIT DO
- END IF
- END SELECT
- SELECT CASE special$
- CASE "0" TO "9"
- IF Choice$ <= special$ THEN
- keychoice = ASC(Choice$)
- ELSE
- keychoice = 0
- END IF
- CASE "@"
- IF UCASE$(Choice$) >= "A" AND UCASE$(Choice$) <= "Z" OR Choice$ = " " OR Choice$ = CHR$(8) THEN
- keychoice = ASC(Choice$)
- ELSE
- keychoice = 0
- END IF
- CASE "*"
- IF UCASE$(Choice$) = "Y" OR UCASE$(Choice$) = "N" OR Choice$ = " " THEN
- keychoice = ASC(Choice$)
- ELSE
- keychoice = 0
- END IF
- CASE "|"
- IF UCASE$(Choice$) = "M" OR UCASE$(Choice$) = "F" OR Choice$ = " " THEN
- keychoice = ASC(Choice$)
- ELSE
- keychoice = 0
- END IF
- CASE "~"
- IF UCASE$(Choice$) = "" THEN
- keychoice = ASC(Choice$)
- ELSE
- keychoice = 0
- END IF
- END SELECT
- SELECT CASE keychoice
- CASE SPACE TO 126
- SELECT CASE caseflag
- CASE 1
- Choice$ = UCASE$(Choice$)
- keychoice = ASC(Choice$)
- CASE 2
- Choice$ = LCASE$(Choice$)
- keychoice = ASC(Choice$)
- END SELECT
- IF insertmode = 0 THEN
- MID$(work$, curpos, 1) = CHR$(keychoice)
- curpos = curpos + 1
- IF firsttime = 1 THEN
- work$ = Choice$ + STRING$(LENGTH - 1, " ")
- work$ = userSformat$((work$), format$)
- firsttime = 0
- END IF
- END IF
- IF insertmode = 1 THEN
- FOR j = 1 TO LENGTH
- Character$ = MID$(format$, j, 1)
- IF INSTR(formatVALUES$, Character$) THEN
- MID$(work$, j, 1) = CHR$(255)
- cursor = cursor + 1
- END IF
- NEXT j
- IF curpos < LENGTH THEN
- lwork$ = LTRIM$(LEFT$(work$, curpos - 1))
- rwork$ = RTRIM$(RIGHT$(work$, LENGTH - (curpos - 1)))
- work$ = LEFT$(lwork$ + Choice$ + rwork$, LENGTH)
- curpos = curpos + 1
- ELSE
- BEEP
- END IF
- work$ = RemoveCHAR$((work$), CHR$(255))
- work$ = userSformat$((work$), format$)
- END IF
- CASE 8, 127
- IF curpos > 1 THEN
- curpos = curpos - 1
- DO
- IF curpos > 1 THEN
- IF INSTR(formatVALUES$, MID$(format$, curpos, 1)) THEN
- curpos = curpos - 1
- ELSE
- EXIT DO
- END IF
- ELSE
- EXIT DO
- END IF
- LOOP
- FOR j = 1 TO LENGTH
- Character$ = MID$(format$, j, 1)
- IF INSTR(formatVALUES$, Character$) THEN
- MID$(work$, j, 1) = CHR$(255)
- END IF
- NEXT j
- IF curpos < LENGTH THEN
- FOR j = curpos TO leng
- IF j < LENGTH - 1 THEN
- char$ = MID$(work$, j + 1, 1)
- MID$(work$, j, 1) = char$
- MID$(work$, LENGTH, 1) = CHR$(255)
- END IF
- NEXT j
- END IF
- MID$(work$, curpos, 1) = CHR$(255)
- work$ = RemoveCHAR$((work$), CHR$(255))
- work$ = userSformat$((work$), format$)
- END IF
- CASE ELSE
- END SELECT
- ELSE
- keychoice = ASC(MID$(Choice$, 2))
- SELECT CASE keychoice
- CASE LEFTK
- IF curpos > 1 THEN
- curpos = curpos - 1
- DO
- IF curpos > 1 THEN
- IF INSTR(formatVALUES$, MID$(format$, curpos, 1)) THEN
- curpos = curpos - 1
- ELSE
- EXIT DO
- END IF
- ELSE
- EXIT DO
- END IF
- LOOP
- END IF
- CASE RIGHTK
- curpos = curpos + 1
- CASE HOME
- curpos = 1
- CASE ENDK
- curpos = LENGTH
- CASE INSERTK
- insertmode = 1 - insertmode
- CASE DELETEK
- FOR j = 1 TO LENGTH
- Character$ = MID$(format$, j, 1)
- IF INSTR(formatVALUES$, Character$) THEN
- MID$(work$, j, 1) = CHR$(255)
- END IF
- NEXT j
- IF curpos < LENGTH THEN
- FOR j = curpos TO leng
- IF j < LENGTH - 1 THEN
- char$ = MID$(work$, j + 1, 1)
- MID$(work$, j, 1) = char$
- MID$(work$, LENGTH, 1) = CHR$(255)
- END IF
- NEXT j
- END IF
- MID$(work$, curpos, 1) = CHR$(255)
- work$ = RemoveCHAR$((work$), CHR$(255))
- work$ = userSformat$((work$), format$)
- CASE F1
- GetBackground 1, 1, 25, 80, hpbuf$
- Hlp$(1) = "- ALPHANUMERIC EDIT HELP -"
- Hlp$(2) = ""
- Hlp$(3) = "ESC - restores edit field. " + CHR$(255)
- Hlp$(4) = "ENTER - accepts entry and exits Edit. " + CHR$(255)
- Hlp$(5) = "CTRL E - erases edit field. " + CHR$(255)
- Hlp$(6) = "DELETE, INSERT, and BACKSPACE function normal. " + CHR$(255)
- Hlp$(7) = "ANY non edit key erases field if first time entry."
- Hlp$(8) = ""
- Hlp$(9) = "Press any key to continue"
- Message Hlp$(), 9, 1, WHITE + 8, RED, WHITE + 8, RED
- 'COLOR efg, ebg
- PutBackground 1, 1, hpbuf$: hpbuf$ = ""
- CASE F10
- IF F10flag = TRUE THEN
- Exitcode = 9
- EXIT DO
- END IF
- CASE UPK
- IF UPflag = TRUE THEN
- Exitcode = 1
- EXIT DO
- END IF
- CASE PGUP
- IF PGUPflag = TRUE THEN
- Exitcode = 2
- EXIT DO
- END IF
- CASE PGDN
- IF PGDNflag = TRUE THEN
- Exitcode = 4
- EXIT DO
- END IF
- CASE DOWNK
- IF DNflag = TRUE THEN
- Exitcode = 3
- EXIT DO
- END IF
- CASE ELSE
- END SELECT
- END IF
- firsttime = 0
- LOOP WHILE Exitcode = 0
- 'COLOR ebg, efg
- LOCATE ROW, col, CURSOROFF
- 'PRINT work$;
- pnc work$, ROW, col, EBG, EFG
-
- FOR j = 1 TO LENGTH
- Character$ = MID$(format$, j, 1)
- char$ = MID$(work$, j, 1)
- IF INSTR(formatVALUES$, Character$) THEN
- ELSE
- IF char$ = CHR$(255) THEN
- ELSE
- tmp$ = tmp$ + char$
- END IF
- END IF
- NEXT j
- FES$ = RTRIM$(LTRIM$(tmp$))
- IF SB = TRUE THEN
- PutBackground ROW, col, ed$: ed$ = ""
- END IF
- END FUNCTION
-
- '
- FUNCTION FileExists (FeName$)
-
- IF LEN(DIR$(FeName$)) = 0 THEN 'Ensure filespec is valid.
- FileExists = 0 'It's not.
- ELSE
- FileExists = 1 'It is.
- END IF
-
- ' code for QB45
-
- ' ffile = FREEFILE
- ' OPEN FeName$ FOR RANDOM AS ffile
- ' IF LOF(ffile) = 0 THEN
- ' FileExists = 0
- ' CLOSE ffile
- ' KILL FeName$
- ' ELSE
- ' FileExists = 1
- ' CLOSE ffile
- ' END IF
-
- END FUNCTION
-
- '
- SUB FormatDEC (number$, beforeDEC, afterdec)
-
- LENGTH = LEN(number$)
- delimit = INSTR(number$, ".")
- IF delimit = 0 THEN
- beforeDEC = LENGTH
- afterdec = 0
- END IF
- IF delimit <> 0 THEN
- IF LEFT$(number$, 1) = "." THEN
- beforeDEC = 0
- afterdec = LENGTH - 1
- END IF
- IF RIGHT$(number$, 1) = "." THEN
- afterdec = 0
- beforeDEC = LENGTH - 1
- END IF
- IF delimit <> 1 OR delimit <> LENGTH THEN
- beforeDEC = delimit - 1
- afterdec = (LENGTH - beforeDEC) - 1
- END IF
- END IF
- IF LENGTH = 0 THEN
- beforeDEC = 0
- afterdec = 0
- END IF
- END SUB
-
- '
- SUB GetBackground (row1, col1, row2, col2, buffer$) STATIC
- ' ========================================
- IF row1 >= 1 AND row2 <= MAXROW AND col1 >= 1 AND col2 <= MAXCOL THEN
- Wid = col2 - col1 + 1
- Hei = row2 - row1 + 1
- size = 4 + (2 * Wid * Hei)
- buffer$ = SPACE$(size)
- CALL getcopybox(row1, col1, row2, col2, buffer$)
- END IF
- END SUB
-
- FUNCTION GetDate$ STATIC
- Month$ = LEFT$(DATE$, 2)
- Day$ = MID$(DATE$, 4, 2)
- Year$ = RIGHT$(DATE$, 2)
- GetDate$ = Month$ + Day$ + Year$
- END FUNCTION
-
- SUB GetDir (ans$)
-
- SHARED FileCount
- IF ans$ = "" THEN
- MsgOpt$(1) = "Enter a file specification:"
- ans$ = "*.*"
- DialogBox MsgOpt$(), 1, 1, 12, BLACK, WHITE, BLACK, WHITE, 3, ans$, "", Exk
- END IF
- filespec$ = ans$
- delimit = INSTR(filespec$, ".")
- IF delimit THEN
- FileName$ = LEFT$(filespec$, delimit - 1)
- fileext$ = RIGHT$(filespec$, LEN(filespec$) - (delimit))
- ELSE
- FileName$ = filespec$
- fileext$ = ""
- END IF
- IF LEN(filespec$) = 0 OR LEN(FileName$) > 8 OR LEN(fileext$) > 3 THEN
- MsgOpt$(1) = "You didn't enter a valid file specification."
- MsgOpt$(2) = ""
- MsgOpt$(3) = "Press any key to continue"
- Message MsgOpt$(), 3, 3, BLACK, WHITE + 8, BLACK, WHITE
- EXIT SUB
- END IF
- FileCount = GetFileCount(filespec$)
- IF FileCount THEN
- REDIM filelist$(FileCount)
- ELSE
- MsgOpt$(1) = "No files could be found."
- MsgOpt$(2) = ""
- MsgOpt$(3) = "Press any key to continue"
- Message MsgOpt$(), 3, 3, BLACK, WHITE + 8, BLACK, WHITE
- EXIT SUB
- END IF
- flist$ = DIR$(filespec$)
- delimit = INSTR(flist$, ".")
- IF delimit THEN
- FileName$ = LEFT$(flist$, delimit - 1)
- FileName$ = FileName$ + STRING$(8 - LEN(FileName$), " ")
- fileext$ = RIGHT$(flist$, LEN(flist$) - (delimit))
- ELSE
- FileName$ = flist$
- fileext$ = ""
- END IF
- filelist$(1) = FileName$ + "." + fileext$
- FOR Indx = 2 TO FileCount
- flist$ = DIR$
- delimit = INSTR(flist$, ".")
- IF delimit THEN
- FileName$ = LEFT$(flist$, delimit - 1)
- FileName$ = FileName$ + STRING$(8 - LEN(FileName$), " ")
- fileext$ = RIGHT$(flist$, LEN(flist$) - (delimit))
- ELSE
- FileName$ = flist$
- fileext$ = ""
- END IF
- filelist$(Indx) = FileName$ + "." + fileext$
- NEXT Indx
- IF FileCount <= 15 THEN
- leftREC = FileCount
- ELSE
- leftREC = 15
- END IF
-
- CALL quicksort(filelist$(), FileCount)
-
- END SUB
-
- '
- FUNCTION GetFileCount (filespec$)
- count = 0
- FileName$ = DIR$(filespec$)
- DO WHILE FileName$ <> ""
- count = count + 1
- FileName$ = DIR$
- LOOP
- GetFileCount = count
- END FUNCTION
-
- '
- FUNCTION GetPassword$ (FrmFG, FrmBG, GenFG, GenBG, DispPos, Ek)
-
- ' DispPos - Section of the screen to display on
- ' 0=Top,1=Center,2=Bottom
- ' Ek - Exit Key
- ' 5=Return, 7=ESC
- mop$ = "Enter your password ---->"
-
- LENGTH = LEN(mop$) + 1
- height = 1 ' Text height
- height = height + 2 'input line
- IF height > 25 THEN
- EXIT FUNCTION
- END IF
- IF LENGTH < 1 THEN
- EXIT FUNCTION
- END IF
-
- SELECT CASE DispPos
- CASE 0
- begin = 1
- CASE 1
- begin = (25 - height) / 2
- CASE 2
- begin = (25 - height) + 1
- CASE ELSE
- EXIT FUNCTION
- END SELECT
-
- Txwd = LENGTH
- BoxWidth = Txwd + 2
- LeftCol = (80 - (BoxWidth + 8)) / 2
- Wid = BoxWidth
- FrameType = 1
- Fill = 1
-
- GetBackground begin, LeftCol, begin + height + 1, LeftCol + Wid + 10, gpbuf$
-
- DrawBox begin, LeftCol, Wid - 1, height, FrameType, FrmFG, FrmBG, Fill, GenFG, GenBG, 1
- pnc mop$, begin + 1, LeftCol + 1, GenFG, GenBG
- DrawBox begin, LeftCol + LENGTH + 1, 10, 3, 1, FrmFG, FrmBG, Fill, GenFG, GenBG, 1
-
- xc = LeftCol + 2
- yc = begin + 1
- np = 0
-
- p$ = ""
-
- FOR x = 1 TO 8
-
- next.char:
- PE$ = INKEY$
- IF PE$ = "" THEN
- GOTO next.char
- ELSE
- SELECT CASE PE$
- CASE "A" TO "Z", "a" TO "z", "0" TO "9"
- CASE ELSE
- GOTO carrage.ret
- END SELECT
- END IF
- p$ = p$ + PE$
-
- curpos = xc + LENGTH
- pnc "#", yc, curpos + np, GenFG, GenBG
- np = np + 1
-
- NEXT
-
- GetPassword$ = p$
- PutBackground begin, LeftCol, gpbuf$: gpbuf$ = ""
-
- EXIT FUNCTION
-
- carrage.ret:
- IF ASC(PE$) = 13 THEN
- GOTO no.password
- ELSE
- GOTO next.char
- END IF
- no.password:
-
- IF p$ = "" THEN
- p$ = "password"
- END IF
- GetPassword$ = p$
- PutBackground begin, LeftCol, gpbuf$: gpbuf$ = ""
-
- END FUNCTION
-
- FUNCTION GetShiftState (bit)
-
- ' =======================================================================
- ' Returns the shift state after calling interrupt 22
- ' bit 0 : RIGHT shift
- ' 1 : LEFT shift
- ' 2 : ctrl key
- ' 3 : alt key
- ' 4 : scroll lock
- ' 5 : num lock
- ' 6 : caps lock
- ' 7 : insert state
- ' =======================================================================
-
- IF bit >= 0 AND bit <= 7 THEN
- DIM regs AS RegType
- regs.ax = 2 * 256
- Interrupt 22, regs, regs
-
- IF regs.ax AND 2 ^ bit THEN
- GetShiftState = TRUE
- ELSE
- GetShiftState = FALSE
- END IF
-
- ELSE
- GetShiftState = FALSE
- END IF
- END FUNCTION
-
- SUB GetSingle (keycode, codetype) STATIC
- codetype = 0
-
- WHILE codetype = 0
- keypress$ = ""
- WHILE keypress$ = ""
- keypress$ = INKEY$
- WEND
- codetype = LEN(keypress$)
- keycode = ASC(MID$(keypress$, codetype))
- WEND
- END SUB
-
- DEFSNG A-Z
- SUB keysort (List$(), numelements%, Startpos%, Sortlen%) STATIC
-
- TempStackSize% = 50
- DIM TempStack%(TempStackSize%)
- Initialize:
- TempStackPnt% = 0
- top% = LBOUND(List$)
- Bottom% = numelements%
- DoSort:
- temp$ = MID$(List$((Bottom% + top%) / 2), Startpos%, Sortlen%)
- I% = top%
- j% = Bottom%
- Part.Exchg:
- DO WHILE MID$(List$(I%), Startpos%, Sortlen%) < temp$
- I% = I% + 1
- LOOP
- DO WHILE MID$(List$(j%), Startpos%, Sortlen%) > temp$
- j% = j% - 1
- LOOP
- IF I% > j% THEN
- GOTO PushTempStack
- END IF
- IF I% < j% THEN
- SWAP List$(I%), List$(j%)
- END IF
- I% = I% + 1
- j% = j% - 1
- IF I% <= j% THEN
- GOTO Part.Exchg
- END IF
- PushTempStack:
- IF I% < Bottom% THEN
- TempStack%(TempStackPnt%) = I%
- TempStack%(TempStackPnt% + 1) = Bottom%
- TempStackPnt% = TempStackPnt% + 2
- END IF
- Bottom% = j%
- IF top% < Bottom% THEN
- GOTO DoSort
- END IF
- IF TempStackPnt% = 0 THEN
- GOTO Exit.Sort
- END IF
- TempStackPnt% = TempStackPnt% - 2
- top% = TempStack%(TempStackPnt%)
- Bottom% = TempStack%(TempStackPnt% + 1)
- GOTO DoSort
- Exit.Sort:
- ERASE TempStack%
- temp$ = ""
- END SUB
-
- DEFINT A-Z
- FUNCTION Maximum (v1, v2)
- IF v1 >= v2 THEN
- Maximum = v1
- ELSE
- Maximum = v2
- END IF
- END FUNCTION
-
- '
- FUNCTION MenuBar (ROW, col, MenuStr$, MenuFore, MenuBack, Reversed, SP)
- DIM menu(1 TO 20) AS MenuData
- MenuLen = LEN(MenuStr$)
- IF MenuLen + col > 80 THEN
- CLS
- LOCATE 10, 20
- PRINT "Cannot create menu - String too long";
- LOCATE 11, 20
- PRINT "Please shorten length of either Menu$ or Col";
- END
- END IF
- menuCHAR = 0
- pnc MenuStr$, ROW, col, MenuFore, MenuBack
- FOR menuCHAR = col TO col + MenuLen - 1
- Test = SCREEN(ROW, menuCHAR)
- IF Test > 64 AND Test < 91 THEN
- menunum = menunum + 1
- menu(menunum).WordStart = menuCHAR
- menu(menunum).MenuLetter = CHR$(Test)
- menu(menunum).MenuWord = CHR$(Test)
- menu(menunum).WordLen = 1
- CharString$ = CHR$(Test)
- ELSEIF Test <> 32 THEN
- CharString$ = CharString$ + CHR$(Test)
- menu(menunum).MenuWord = CharString$
- menu(menunum).WordLen = menu(menunum).WordLen + 1
- END IF
- NEXT menuCHAR
- menunum = SP
- DO
- COLOR , MenuBack
- FOR menuCHAR = 1 TO 20
- IF menu(menuCHAR).WordStart > 0 THEN
- COLOR Reversed
- LOCATE ROW, menu(menuCHAR).WordStart
- PRINT menu(menuCHAR).MenuLetter;
- Lastmenu = menuCHAR
- ELSE
- menuCHAR = 20
- END IF
- NEXT menuCHAR
- LOCATE ROW, menu(menunum).WordStart
- COLOR WHITE + 8, Reversed
- PRINT RTRIM$(menu(menunum).MenuWord);
- DO
- Response$ = UCASE$(INKEY$)
- SELECT CASE Response$
- CASE CHR$(0) + CHR$(75)
- GOSUB ResetSel
- menunum = menunum - 1
- IF menunum < 1 THEN
- menunum = Lastmenu
- END IF
- CASE CHR$(0) + CHR$(77)
- GOSUB ResetSel
- menunum = menunum + 1
- IF menunum > Lastmenu THEN
- menunum = 1
- END IF
- CASE CHR$(13)
- MenuBar = menunum
- CASE "A" TO "Z"
- FOR Compare = 1 TO 20
- IF Response$ = menu(Compare).MenuLetter THEN
- menunum = Compare
- MenuBar = menunum
- Response$ = CHR$(13)
- END IF
- NEXT Compare
- CASE ELSE
- END SELECT
- LOOP UNTIL Response$ <> ""
- LOOP UNTIL Response$ = CHR$(13)
- EXIT FUNCTION
- ResetSel:
- LOCATE ROW, col
- COLOR MenuFore, MenuBack
- LOCATE ROW, menu(menunum).WordStart
- PRINT RTRIM$(menu(menunum).MenuWord);
- COLOR Reversed
- LOCATE ROW, menu(menunum).WordStart
- PRINT RTRIM$(menu(menunum).MenuLetter);
- RETURN
- END FUNCTION
-
- '
- FUNCTION MenuWindow (ROW, col, MenuStr$, title$, MenuFore, MenuBack, Reversed, allowesc)
- DIM menu(1 TO 20) AS MenuData
- Array$ = Str2Token$(MenuStr$, "\")
- I = 0
- LENGTH = 0
- DO
- I = I + 1
- moption$(I) = Array$
- IF LEN(moption$(I)) > LENGTH THEN
- LENGTH = LEN(moption$(I))
- END IF
- Array$ = Str2Token$("", "\")
- LOOP WHILE Array$ <> ""
-
- menuCHAR = 0
-
- IF col > 80 - LENGTH THEN
- col = (80 - LENGTH)
- END IF
- IF ROW > 23 - I THEN
- ROW = (24 - I)
- END IF
- IF col <= 1 THEN
- col = (80 - LENGTH) / 2
- END IF
- IF ROW <= 1 THEN
- ROW = (24 - I) / 2
- END IF
- GetBackground ROW - 1, col - 1, ROW + I + 2, col + LENGTH + 4, mwbuf$
- FOR j = 1 TO I
- pnc " " + moption$(j) + STRING$(LENGTH - LEN(moption$(j)) + 1, " "), ROW + j, col, MenuFore, MenuBack
- NEXT j
- LeftCol = col - 1: TopRow = ROW: endcol = col + LENGTH: endrow = ROW + j
- DrawBox TopRow, LeftCol, LENGTH + 4, j + 1, 2, MenuFore, MenuBack, 0, 7, 0, 1
- tx$ = RTRIM$(title$)
- IF LEN(tx$) > 0 THEN
- lgth = endcol - LeftCol
- IF (LEN(tx$) + 2) < lgth THEN
- pnc "[" + tx$ + "]", TopRow, LeftCol + INT(lgth / 2 - LEN(tx$) / 2), MenuFore + 1, MenuBack
- ELSE
- pnc LEFT$("|" + tx$ + "|", (endcol - LeftCol + 3)), TopRow - 1, LeftCol + 3, MenuFore, MenuBack
- END IF
- END IF
- FOR menuCHAR = ROW + 1 TO ROW + I
- Test = SCREEN(menuCHAR, col + 1)
- SELECT CASE Test
- CASE 64 TO 91, 47 TO 58
- menunum = menunum + 1
- menu(menunum).WordStart = menuCHAR
- menu(menunum).MenuLetter = CHR$(Test)
- menu(menunum).MenuWord = CHR$(Test)
- menu(menunum).WordLen = 1
- CharString$ = CHR$(Test)
- CASE IS <> 32
- CharString$ = CharString$ + CHR$(Test)
- menu(menunum).MenuWord = CharString$
- menu(menunum).WordLen = menu(menunum).WordLen + 1
- END SELECT
- NEXT menuCHAR
- menunum = 1
- DO
- FOR menuCHAR = 1 TO 20
- IF menu(menuCHAR).WordStart > 0 THEN
- pnc menu(menuCHAR).MenuLetter, menu(menuCHAR).WordStart, col + 1, Reversed, MenuBack
- Lastmenu = menuCHAR
- ELSE
- menuCHAR = 20
- END IF
- NEXT menuCHAR
- pnc " " + RTRIM$(moption$(menunum)) + STRING$(LENGTH - LEN(moption$(menunum)) + 1, " "), menu(menunum).WordStart, col, WHITE + 8, Reversed
- DO
- Response$ = UCASE$(INKEY$)
- SELECT CASE Response$
- CASE CHR$(0) + CHR$(72)
- pnc " " + RTRIM$(moption$(menunum)) + STRING$(LENGTH - LEN(moption$(menunum)) + 1, " "), menu(menunum).WordStart, col, MenuFore, MenuBack
- pnc " " + menu(menunum).MenuLetter, menu(menunum).WordStart, col, MenuFore, MenuBack
- menunum = menunum - 1
- IF menunum < 1 THEN
- menunum = Lastmenu
- END IF
- CASE CHR$(0) + CHR$(80)
- pnc " " + RTRIM$(moption$(menunum)) + STRING$(LENGTH - LEN(moption$(menunum)) + 1, " "), menu(menunum).WordStart, col, MenuFore, MenuBack
- pnc " " + menu(menunum).MenuLetter, menu(menunum).WordStart, col, MenuFore, MenuBack
- menunum = menunum + 1
- IF menunum > Lastmenu THEN
- menunum = 1
- END IF
- CASE CHR$(13)
- MenuWindow = menunum
- CASE CHR$(27)
- IF allowesc = 1 THEN
- Response$ = CHR$(13)
- MenuWindow = 0
- END IF
- CASE "A" TO "Z", "0" TO "9"
- FOR Compare = 1 TO 20
- IF Response$ = menu(Compare).MenuLetter THEN
- menunum = Compare
- MenuWindow = menunum
- Response$ = CHR$(13)
- END IF
- NEXT Compare
- CASE ELSE
- END SELECT
- LOOP UNTIL Response$ <> ""
- LOOP UNTIL Response$ = CHR$(13)
- PutBackground ROW - 1, col - 1, mwbuf$: mwbuf$ = ""
- END FUNCTION
-
- '
- SUB Message (mop$(), lines, Border, FrmFG, FrmBG, GenFG, GenBG)
- maxwidth = 0
- El = UBOUND(mop$, 1)
- IF lines > El THEN
- EXIT SUB
- END IF
- FOR j = 1 TO lines
- Trim mop$(j)
- maxwidth = Maximum(maxwidth, LEN(mop$(j)))
- NEXT j
- maxwidth = maxwidth + 4
- maxheight = lines + 4
- IF maxwidth > 80 THEN
- EXIT SUB
- END IF
- IF maxheight > 24 THEN
- EXIT SUB
- END IF
- TopRow = 24 - maxheight
- TopRow = TopRow / 2
- LeftCol = 80 - maxwidth
- LeftCol = LeftCol / 2
- GetBackground TopRow, LeftCol, TopRow + maxheight + 1, LeftCol + maxwidth + 1, msbuf$
- DrawBox TopRow, LeftCol, maxwidth, maxheight, Border, FrmFG, FrmBG, 1, GenFG, GenBG, 1
-
- FOR j = 1 TO lines
- Diff = (maxwidth - LEN(mop$(j)))
- IF Diff THEN
- Diff = Diff / 2
- END IF
- TextToPrint$ = mop$(j)
- ROW = j + TopRow + 1
- col = LeftCol + Diff
- pnc TextToPrint$, ROW, col, GenFG, GenBG
- NEXT j
- DO
- key$ = INKEY$
- LOOP UNTIL key$ <> ""
- PutBackground TopRow, LeftCol, msbuf$: msbuf$ = ""
- END SUB
-
- FUNCTION Minimum (v1, v2)
- IF v1 >= v2 THEN
- Minimum = v2
- ELSE
- Minimum = v1
- END IF
- END FUNCTION
-
- '
- SUB msg.nodata
- DIM DispLine$(4)
- DispLine$(1) = " There are no records "
- DispLine$(2) = "in the database !"
- DispLine$(3) = ""
- DispLine$(4) = "Press any key to continue"
- Message DispLine$(), 4, 3, BLACK, WHITE, balck, WHITE
- END SUB
-
- SUB MsgLine (msg$, lin, mfg, mfb) STATIC
-
- CALL pnc(SPACE$(77), lin, 2, mfg, mfb)
- ml = 80 - LEN(msg$)
- mp = ml \ 2
- CALL pnc(msg$, lin, mp, mfg, mfb)
-
- END SUB
-
- SUB nodata
- DIM DispLine$(4)
- DispLine$(1) = "There are no Records"
- DispLine$(2) = "in the database !"
- DispLine$(3) = ""
- DispLine$(4) = "Press any key to continue"
- Message DispLine$(), 4, 3, BLACK, WHITE, balck, WHITE
-
- END SUB
-
- '
- FUNCTION OpenFile (FileName$, reclen)
- IF FileExists(FileName$) THEN
- w = FREEFILE
- IF w THEN
- OPEN FileName$ FOR RANDOM AS #w LEN = reclen
- OpenFile = w
- ELSE
- OpenFile = 0
- END IF
- ELSE
- OpenFile = 0
- END IF
- END FUNCTION
-
- SUB PadStr (a$, b)
- IF LEN(a$) >= b THEN
- a$ = LEFT$(a$, b)
- ELSE
- a$ = a$ + STRING$(b - LEN(a$), 32)
- END IF
- END SUB
-
- '
- SUB PutBackground (ROW, col, buffer$)
- ' =======================================================================
- ' This sub checks the boundries before executing the put command
- ' =======================================================================
- IF ROW >= 1 AND ROW <= MAXROW AND col >= 1 AND col <= MAXCOL THEN
- CALL putcopybox(ROW, col, buffer$)
- END IF
- END SUB
-
- DEFSNG A-U, W-Z
- DEFDBL V
- SUB quicksort (fl$(), Elements%) STATIC
- DIM tempstk%(30, 2)
- s% = 1
- tempstk%(1, 1) = 1
- tempstk%(1, 2) = Elements%
- DO WHILE s% <> 0
- l% = tempstk%(s%, 1)
- r% = tempstk%(s%, 2)
- s% = s% - 1
- DO WHILE l% < r%
- I% = l%
- j% = r%
- x$ = fl$((l% + r%) / 2)
- DO WHILE j% >= I%
- DO WHILE fl$(I%) < x$
- I% = I% + 1
- LOOP
- DO WHILE x$ < fl$(j%)
- j% = j% - 1
- LOOP
- IF I% <= j% THEN
- SWAP fl$(j%), fl$(I%)
- I% = I% + 1
- j% = j% - 1
- END IF
- LOOP
- IF I% < r% THEN
- s% = s% + 1
- tempstk%(s%, 1) = I%
- tempstk%(s%, 2) = r%
- END IF
- r% = j%
- LOOP
- LOOP
- END SUB
-
- DEFINT A-Z
- '
- SUB Reg16to8 (Reg16 AS LONG, RegHigh AS INTEGER, RegLow AS INTEGER)
-
- RegHigh = Reg16 \ 256
- RegLow = Reg16 MOD 256
-
- END SUB
-
- '
- SUB Reg8to16 (Reg16 AS LONG, RegHigh AS INTEGER, RegLow AS INTEGER)
-
- Reg16 = RegHigh * 256 + RegLow
-
- END SUB
-
- SUB Reg8to4 (Reg8, RegHigh, RegLow)
- RegHigh = Reg8 \ 16
- RegLow = Reg8 MOD 16
- END SUB
-
- FUNCTION RemoveCHAR$ (userstring$, skip$)
- LENGTH = LEN(userstring$)
- Character$ = ""
- FOR k = 1 TO LENGTH
- char$ = MID$(userstring$, k, 1)
- IF char$ = skip$ THEN
- ELSE
- Character$ = Character$ + char$
- END IF
- NEXT
- RemoveCHAR$ = Character$
- END FUNCTION
-
- FUNCTION removeformat$ (work$, format$) STATIC
- IF LEN(work$) < LEN(format$) THEN
- EXIT FUNCTION
- END IF
- LENGTH = LEN(format$)
- FOR j = 1 TO LENGTH
- FChr$ = MID$(format$, j, 1)
- SELECT CASE FChr$
- CASE "~", "@", "0" TO "9", "#", "*"
- CASE ELSE
- formatVALUES$ = formatVALUES$ + FChr$
- END SELECT
- NEXT j
- FOR j = 1 TO LENGTH
- Character$ = MID$(format$, j, 1)
- char$ = MID$(work$, j, 1)
- IF INSTR(formatVALUES$, Character$) THEN
- ELSE
- IF char$ = CHR$(255) THEN
- ELSE
- tmp$ = tmp$ + char$
- END IF
- END IF
- NEXT j
- removeformat$ = RTRIM$(LTRIM$(tmp$))
- END FUNCTION
-
- '
- FUNCTION SelBox (TempKey$(), numele, lenview, diswide, fg, bg, rev) STATIC
- numele = numele
- diswide = diswide + 1
- COLOR fg, bg
-
- GetBackground 21, 5, 23, 75, sfm$
- CALL drawwind(21, 5, 23, 75, 2, 0)
- 'color frame
- CALL Colorwind(21, 5, 23, 75, 0, 1, BLACK, WHITE)
-
- CenterText " Select From List and Press Enter ", 22, BLACK, WHITE
-
- LOCATE , , 0
- FOR j = 1 TO numele
- IF LEN(TempKey$(j)) < diswide THEN
- TempKey$(j) = TempKey$(j) + STRING$(diswide - LEN(TempKey$(j)), 32)
- END IF
- NEXT j
- height = lenview + 2
- LeftCol = (80 / 2) - (diswide / 2)
- TopRow = (25 - height) / 2
- rightcol = LeftCol + diswide - 1
- botrow = TopRow + height - 4
- rtside = LeftCol + diswide + 1
- topline = TopRow + 1
- botline = TopRow + lenview + 2
- GetBackground topline, LeftCol, botline + 1, rtside + 2, sbbuf$
- DrawBox topline, LeftCol, diswide + 2, height, 2, fg, bg, 1, fg, bg, 1
- lup = 0
- linepos = 1
- listpos = 1
- WHILE lup = 0
- FOR j = 1 TO lenview
- IF (j - 1) + listpos <= numele THEN
- IF j = linepos THEN
- COLOR bg + 8, rev
- LOCATE j + TopRow + 1, LeftCol + 1
- PRINT TempKey$(j - 1 + listpos);
- END IF
- IF j <> linepos THEN
- COLOR fg, bg
- LOCATE j + TopRow + 1, LeftCol + 1
- PRINT TempKey$(j - 1 + listpos);
- END IF
- ELSE
- LOCATE j + TopRow + 1, LeftCol + 1
- PRINT STRING$(diswide, 32);
- END IF
- NEXT j
- keytype = 0
- WHILE keytype = 0
- Choice$ = ""
- WHILE Choice$ = ""
- Choice$ = INKEY$
- WEND
- keytype = LEN(Choice$)
- keychoice = ASC(MID$(Choice$, keytype))
- WEND
- IF keytype = 2 THEN
- SELECT CASE keychoice
- CASE 72
- linepos = linepos - 1
- CASE 80
- linepos = linepos + 1
- CASE 81
- listpos = listpos + lenview
- CASE 73
- listpos = listpos - lenview
- CASE 79
- listpos = (numele + 1) - lenview
- linepos = lenview
- CASE 71
- listpos = 1
- linepos = 1
- END SELECT
- END IF
- IF keytype = 1 THEN
- IF keychoice = 13 THEN
- lup = 1
- END IF
- END IF
- IF linepos < 1 THEN
- listpos = listpos - 1
- linepos = 1
- END IF
- IF linepos > lenview THEN
- listpos = listpos + 1
- linepos = lenview
- END IF
- IF (listpos - 1 + lenview) > numele THEN
- listpos = numele - lenview + 1
- END IF
- IF linepos > numele THEN
- linepos = numele
- END IF
- IF listpos < 1 THEN
- listpos = 1
- END IF
- WEND
- SelBox = listpos + linepos - 1
- COLOR 7, 0
- PutBackground topline, LeftCol, sbbuf$: sbbuf$ = ""
- PutBackground 21, 5, sfm$: sfm$ = ""
- END FUNCTION
-
- '
- FUNCTION SelFiles$ (userfilespec$)
-
- IF LEN(userfilespec$) = 0 THEN
- MsgOpt$(1) = "Enter a file specification:"
- userfilespec$ = "*.*"
-
- CALL DialogBox(MsgOpt$(), 1, 1, 12, BLACK, WHITE, BLACK, WHITE, 1, userfilespec$, "", Exk)
-
- END IF
-
- filespec$ = userfilespec$
- delimit = INSTR(filespec$, ".")
- IF delimit THEN
- FileName$ = LEFT$(filespec$, delimit - 1)
- fileext$ = RIGHT$(filespec$, LEN(filespec$) - (delimit))
- ELSE
- FileName$ = filespec$
- fileext$ = ""
- END IF
- IF LEN(filespec$) = 0 OR LEN(FileName$) > 8 OR LEN(fileext$) > 3 THEN
- MsgOpt$(1) = "You didn't enter a valid file specification."
- MsgOpt$(2) = ""
- MsgOpt$(3) = "Press any key to continue"
- Message MsgOpt$(), 3, 3, BLACK, WHITE + 8, BLACK, WHITE
- EXIT FUNCTION
- END IF
- FileCount = GetFileCount(filespec$)
- IF FileCount THEN
- REDIM filelist$(FileCount)
- ELSE
- MsgOpt$(1) = "No files could be found."
- MsgOpt$(2) = ""
- MsgOpt$(3) = "Press any key to continue"
- Message MsgOpt$(), 3, 3, BLACK, WHITE + 8, BLACK, WHITE
- EXIT FUNCTION
- END IF
- flist$ = DIR$(filespec$)
- delimit = INSTR(flist$, ".")
- IF delimit THEN
- FileName$ = LEFT$(flist$, delimit - 1)
- FileName$ = FileName$ + STRING$(8 - LEN(FileName$), " ")
- fileext$ = RIGHT$(flist$, LEN(flist$) - (delimit))
- ELSE
- FileName$ = flist$
- fileext$ = ""
- END IF
- filelist$(1) = FileName$ + "." + fileext$
- FOR Indx = 2 TO FileCount
- flist$ = DIR$
- delimit = INSTR(flist$, ".")
- IF delimit THEN
- FileName$ = LEFT$(flist$, delimit - 1)
- FileName$ = FileName$ + STRING$(8 - LEN(FileName$), " ")
- fileext$ = RIGHT$(flist$, LEN(flist$) - (delimit))
- ELSE
- FileName$ = flist$
- fileext$ = ""
- END IF
- filelist$(Indx) = FileName$ + "." + fileext$
- NEXT Indx
- IF FileCount <= 10 THEN
- leftREC = FileCount
- ELSE
- leftREC = 10
- END IF
-
- CALL quicksort(filelist$(), FileCount)
- usel = SelBox(filelist$(), UBOUND(filelist$), leftREC, 12, BLACK, WHITE, RED)
- IF usel = 0 THEN
- SelFiles$ = ""
- ELSE
- SelFiles$ = RemoveCHAR$((filelist$(usel)), " ")
- END IF
-
- END FUNCTION
-
- FUNCTION Str2Token$ (Srce$, DELIM$)
- STATIC Start, SaveStr$
- IF Srce$ <> "" THEN
- Start = 1
- SaveStr$ = Srce$
- END IF
- BegPos = Start
- Ln = LEN(SaveStr$)
- WHILE BegPos <= Ln AND INSTR(DELIM$, MID$(SaveStr$, BegPos, 1)) <> 0
- BegPos = BegPos + 1
- WEND
- IF BegPos > Ln THEN
- Str2Token$ = ""
- EXIT FUNCTION
- END IF
- EndPos = BegPos
- WHILE EndPos <= Ln AND INSTR(DELIM$, MID$(SaveStr$, EndPos, 1)) = 0
- EndPos = EndPos + 1
- WEND
- Str2Token$ = MID$(SaveStr$, BegPos, EndPos - BegPos)
- Start = EndPos
- END FUNCTION
-
- FUNCTION strval$ (a%)
- strval$ = MID$(STR$(a%), 2)
- END FUNCTION
-
- SUB Trim (a$)
- a$ = RTRIM$(LTRIM$(a$))
- END SUB
-
- FUNCTION userNformat$ (wrk$, format$)
- work$ = wrk$
- LENGTH = LEN(format$)
- SELECT CASE LEN(work$)
- CASE IS > LENGTH
- work$ = RIGHT$(work$, LENGTH)
- CASE IS < LENGTH
- work$ = STRING$(LENGTH - LEN(work$) - 1, " ") + work$
- END SELECT
- IF INSTR(format$, ".") THEN
- decflag = 1
- IF INSTR(work$, ".") THEN
- FormatDEC (work$), bforeDEC, aftDEC
- FormatDEC (format$), beforeDEC, afterdec
- work$ = RemoveCHAR$((work$), ".")
- IF afterdec > aftDEC THEN
- work$ = work$ + STRING$(afterdec - (aftDEC - 1), "0")
- END IF
- IF afterdec < aftDEC THEN
- work$ = STRING$(aftDEC - (afterdec - 1), " ") + LEFT$(work$, beforeDEC + (afterdec - 1))
- END IF
- ELSE
- FormatDEC format$, beforeDEC, afterdec
- work$ = work$ + STRING$(afterdec + 1, "0")
- END IF
- ELSE
- FormatDEC (work$), beforeDEC, afterdec
- work$ = LEFT$(work$, beforeDEC)
- afterdec = 0
- work$ = STRING$(LENGTH - LEN(work$), " ") + work$
- decflag = 0
- END IF
- SELECT CASE LEN(work$)
- CASE IS > LENGTH
- work$ = RIGHT$(work$, LENGTH)
- CASE IS < LENGTH
- IF decflag THEN
- work$ = STRING$(LENGTH - LEN(work$) - 1, " ") + work$
- ELSE
- work$ = STRING$(LENGTH - LEN(work$), " ") + work$
- END IF
- END SELECT
- temp$ = work$
- work$ = STRING$(LENGTH, " ")
- k = 1
- FOR j = 1 TO LENGTH
- Character$ = MID$(format$, j, 1)
- IF INSTR(".", Character$) THEN
- MID$(work$, j, 1) = Character$
- ELSE
- char$ = MID$(temp$, k, 1)
- MID$(work$, j, 1) = char$
- k = k + 1
- END IF
- NEXT j
- userNformat$ = work$
- END FUNCTION
-
- FUNCTION userSformat$ (wrk$, format$)
- work$ = wrk$
- LENGTH = LEN(format$)
- FOR j = 1 TO LENGTH
- FChr$ = MID$(format$, j, 1)
- SELECT CASE FChr$
- CASE "~", "@", "0" TO "9", "#", "*"
- CASE ELSE
- formatVALUES$ = formatVALUES$ + FChr$
- END SELECT
- NEXT j
- temp$ = work$
- work$ = STRING$(LENGTH, " ")
- k = 1
- FOR j = 1 TO LENGTH
- Character$ = MID$(format$, j, 1)
- IF INSTR(formatVALUES$, Character$) THEN
- MID$(work$, j, 1) = Character$
- ELSE
- char$ = MID$(temp$, k, 1)
- MID$(work$, j, 1) = char$
- k = k + 1
- END IF
- NEXT j
- userSformat$ = work$
- END FUNCTION
-
- '
- SUB waitkey (ROW, fg, bg)
-
- CONST a$ = "Press any key to continue"
-
- GetBackground ROW, 1, ROW, 80, mb$
- c = 80 - LEN(a$)
- c = c / 2
- pnc a$, ROW, c, fg, bg
- DO
- key$ = INKEY$
- LOOP UNTIL key$ <> ""
- PutBackground ROW, 1, mb$: mb$ = ""
- END SUB
-
-