home *** CD-ROM | disk | FTP | other *** search
- '****************************************************************************
- 'Total Control Systems QuickBasic 4.5
- '****************************************************************************
- '
- ' Program : GETNUMBR.BAS
- ' Written by : Tim Beck
- ' Written On : 10-01-90
- ' Function : GET NUMBER SUB ROUTINES
- '
- '****************************************************************************
- ' This program and those associated with it were written for use with Quick-
- ' Windows Advanced (Version 1.5+). Possesion of this program entitles you
- ' to certain priviliges. They are:
- '
- ' 1. You may compile, use, or modify this program in any way you choose
- ' provided you do not sell or give away the source code to this prog-
- ' ram or any of it's companions to anyone for any reason. You may,
- ' however, sell the resulting executable program as you see fit.
- '
- ' 2. You may modify, enhance or change these programs as you see fit. I
- ' as that you keep a copy of the original code and that you notify
- ' me of any improvements you make. I like to think that the code is
- ' bug free and cannot be improved upon, but I'm sure someone will
- ' find a way to make it better. If it's you, I'm looking forward to
- ' seeing your changes. I can be reached at:
- '
- ' Tim Beck Tim Beck (C/O Debbie Beck)
- ' 19419 Franz Road 8030 Fairchild Avenue
- ' Houston, Texas 77084 Canoga Park, California 91306
- ' (713) 639-3079 (818) 998-0588
- '
- ' 3. This code has been tested and re-tested in a variety of applications
- ' and although I have not found any bugs, doesn't mean none exist. So,
- ' this program along with it's companions comes with NO WARRANTY,
- ' either expressed or implied. I'm sorry if there are problems, but
- ' I can't be responsible for your work. I've tried to provide a safe
- ' and efficient programming enviroment and I hope you find it helpful
- ' for you. I do, however, need to cover my butt!
- '
- ' I have enjoyed creating this library of programs and have found them to be
- ' a great time saver. I hope you agree.
- '
- ' Tim Beck //
- '
- '****************************************************************************
- DECLARE FUNCTION PadS$ (Number$, Padby%, Padwith%)
- DECLARE FUNCTION FreeWind% ()
-
- DECLARE SUB CLOSE.WINDOW (wid%)
-
- DECLARE SUB GETNUMBER (Hdr$, msg$, cpos%, S$, flag%)
- DECLARE SUB GETNUMBER2 (Hdr$, msg1$, msg2$, cpos%, s1$, s2$, flag%)
-
- '------------------------------------------------------------------------
- ' Gets one or two numeric strings from the user
- '
- ' Hdr$ = Header of Input Box
- ' msg$, msg1$ = Message of First Numeric Input Line
- ' msg2$ = Message of Second Input Line
- ' cpos% = Position of Cursor in First numeric Input
- ' s1$ = returned numeric string 1
- ' s2$ = returned numeric string 2
- ' flag% = Input Flag% (1 = OK!)
-
- REM $INCLUDE: 'STDCOM.INC'
-
- TIMER OFF 'Enables Event Trapping
-
- ' ON ERROR GOTO ErrorTrap
-
- ErrorTrap:
-
- ' RESUME
-
- SUB GETNUMBER (Hdr$, msg$, cpos%, S$, flag%) STATIC
-
- cpos% = cpos% - 1
- IF cpos% <= 0 THEN
- cpos% = 0
- END IF
-
- flag% = 1
-
- Style% = Sh.Flag% + EX.Flag% + 1
- edits% = 8483 '(keep contents, no letters, +-, allow INS/DEL, insert/ovrwrt, normal exit when full)
- exits% = 17407 '(all function keys + ESC)
-
- x1% = 80 - ((LEN(msg$) + LEN(S$)) + 6)
- x1% = x1% / 2
- y1% = 10
- x2% = x1% + (LEN(msg$) + LEN(S$)) + 6
- y2% = 14
-
- S$ = PadS$(S$, LEN(S$), 1)
-
- wid% = FreeWind%
- sav% = wid% 'In case of error, wid% will be returned
- 'negative, sav restores original value
- idx% = ((wid% - 1) * 2000) 'each window is allotted 2000 characters
-
- CALL WOPENI(x1%, y1%, x2%, y2%, Style%, S.attr%, Hdr$, w.array%(), idx%, wid%)
- IF wid% <= 0 THEN
- wid% = sav%
- END IF
- CALL WPRINTA(wid%, 2, 1, S.attr%, msg$)
- CALL WLOCATE(wid%, LEN(msg$) + 2, 1)
- CALL WINPUT(wid%, S$, cpos%, edits%, exits%, " 0123456789", kb%, flag%)
-
- S$ = PadS$(S$, LEN(S$), 1)
-
- CALL CLOSE.WINDOW(wid%)
-
- IF flag% = 1 THEN
- flag% = 0
- END IF
-
- END SUB
-
- SUB GETNUMBER2 (Hdr$, msg1$, msg2$, cpos%, s1$, s2$, flag%) STATIC
-
- cpos% = cpos% - 1
- IF cpos% <= 0 THEN
- cpos% = 0
- END IF
-
- flag% = 1
-
- Style% = Sh.Flag% + EX.Flag% + 1
-
- edits% = 8483 '(keep contents, no letters, +-, allow INS/DEL, insert/ovrwrt, normal exit when full)
- exits% = 17407 '(all function keys + ESC)
-
- x1% = 80 - ((LEN(msg1$) + LEN(s1$)) + 6)
- x1% = x1% / 2
- y1% = 9
- x2% = x1% + (LEN(msg1$) + LEN(s1$)) + 6
- y2% = 15
-
- s1$ = PadS$(s1$, LEN(s1$), 1)
- s2$ = PadS$(s2$, LEN(s2$), 1)
-
- wid% = FreeWind%
- sav% = wid% 'In case of error, wid% will be returned
- 'negative, sav restores original value
- idx% = ((wid% - 1) * 2000) 'each window is allotted 2000 characters
-
- CALL WOPENI(x1%, y1%, x2%, y2%, Style%, S.attr%, Hdr$, w.array%(), idx%, wid%)
- IF wid% <= 0 THEN
- wid% = sav%
- END IF
-
- CALL WPRINTA(wid%, 2, 1, S.attr%, msg1$ + s1$)
- CALL WPRINTA(wid%, 2, 3, S.attr%, msg2$ + s2$)
-
- DO
-
- flag% = 1 'Initialize
- CALL WLOCATE(wid%, LEN(msg1$) + 2, 1)
- CALL WINPUT(wid%, s1$, cpos%, edits%, exits%, " 0123456789", kb%, flag%)
- IF kb% = Escape% OR kb% = F.9% THEN
- EXIT SUB
- ELSE
- s1$ = PadS$(s1$, LEN(s1$), 1)
- CALL WPRINTA(wid%, 2, 1, S.attr%, msg1$ + s1$)
- END IF
-
- flag% = 1 'Initialize
- CALL WLOCATE(wid%, LEN(msg2$) + 2, 3)
- CALL WINPUT(wid%, s2$, 0, edits%, exits%, " 0123456789", kb%, flag%)
- s2$ = PadS$(s2$, LEN(s2$), 1)
- CALL WPRINTA(wid%, 2, 3, S.attr%, msg1$ + s2$)
-
- LOOP UNTIL flag% = 1
-
- CALL CLOSE.WINDOW(wid%)
-
- IF flag% = 1 THEN
- flag% = 0
- END IF
-
- END SUB
-
-