home *** CD-ROM | disk | FTP | other *** search
- QBINPUT.SUB - subprogram to build input string in a controlled manner
-
- written by lee bernbaum
- 3478 stone
- memphis, tn 38118
- reachable at GEMS BBS (901)-278-4367
-
- No Charge - use it as you see fit - distribute it freely
-
- What It Is:
-
- QBINPUT is a Quikbasic SUB-PROGRAM that can be called to handle input in
- a reasonably controlled manner, returning a string of a predefined length.
- The input field is filled with whatever character you specify. You can
- control whether or not a CR is required when maximum length is reached,
- thus providing rudimentary word wrapping (until you backspace all the way
- to the beginning of the string...previous line's X,Y values are not saved).
- The cursor is always blinking where the next character will go.
-
- This routine was written because the INPUT command just does not suffice
- for controlled input, and INSTR$ can be a nuisance.
-
- How to use it:
-
- Either merge this code into your Quikbasic program directly, or remember to
- include it via the QB Metacommand REM $INCLUDE: 'QBINPUT.SUB'. Or you can
- compile it to object level, and LINK to the .OBJ file, by doing the
- following:
-
- QB YOURPROG.BAS,,,/E/X/O
- QB QBINPUT.SUB,,,/O
- LINK YOURPROG+QBINPUT
-
- You call this routine from within a program with the command:
-
- CALL GETINP(IX,IY,MAXLEN,FILL,GETKEY$,WRAP)
-
- where IX = The line number (between 1 and 23)
- IY = The column number (between 1 and (79-MAXLEN))
- MAXLEN = The desired length of the string
- FILL = The ASCII decimal value of the desired filler in the
- input area. Example ASCII 42 = *, thus a FILL of 42
- would create an input area filled with asteriks to
- show the user the field length.
- GETKEY$ = The input string returned to the calling program
- WRAP = 1=enable wrapping;anything else reuires a CR to end input
-
- A sample use might be as follows:
- Get Input of a Drive Specification
-
- RF=7:RB=0:INF=1:INB=7 set regular and input colors, if desired
- COLOR RF,RB toggle regular screen color
- IX=5 set row number for line 5 of display
- WRAP=1 enable word wrap
- MAXLEN=25 desired input string maximum 25 characters
- FILL=35 ASCII code for #, desired fill character
- GETKEY$="" doesn't matter - just use first time routine
- 'is called - GETKEY$ is recycled after that
- PRMPT$=chr$(7)+"Please Specify Drive Path: " create a prompt
- LOCATE IX,15:PRINT PRMPT$ position\print prompt in col 15
- IY=15+(LEN(PRMPT$)) calculate input start column
- COLOR INF,INB set for input field colors
- CALL GETINP(IX,IY,MAXLEN,FILL,GETKEY$,WRAP) call the routine
- IF.......the necessary logic to screen a VALID drive path type string
- COLOR RF,RB reset screen color
- Whatever program would do next here
-
- I have found this routine useful in several of my own programs. Between this
- sub-program and event trapping of defined keys, I find it very easy to put
- a tight grip on what my users can do to a program.
-
- Hope you find it useful.
-