home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Zodiac Super OZ
/
MEDIADEPOT.ISO
/
FILES
/
13
/
N_B_V203.ZIP
/
TINPUT2.INC
< prev
next >
Wrap
Text File
|
1996-07-04
|
9KB
|
161 lines
$if 0
┌──────────────────────────╖ PowerBASIC v3.20
┌──┤ DASoft ╟──────────────────────┬──────────────────╖
│ ├──────────────────────────╢ Copyright 1995 │ DATE: 1995-10-01 ╟─╖
│ │ FILE NAME TINPUT2 .INC ║ 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 ║ ║
╘═╤═════════════════════════════════════════════════════════════════════╝ ║
│ .................................... ║
╘═══════════════════════════════════════════════════════════════════════╝
$endif
'.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°
' ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° °
$if 0
$CODE SEG "DAS_NB01"
$EVENT OFF
$ERROR ALL OFF
$OPTIMIZE SIZE
$OPTION GOSUB OFF
$OPTION CNTLBREAK OFF
$OPTION SIGNED OFF
$DEBUG MAP OFF
$DEBUG PATH OFF
$DEBUG UNIT OFF
$COMPILE UNIT
$INCLUDE "\TINPUT.TYP"
DECLARE FUNCTION fHelpLine$ (SEG H$,BYVAL Just%)
DECLARE FUNCTION fTinput$ (SEG D$,BYVAL T$,SEG E$,BYVAL Hattr?,BYVAL Nattr?)
DECLARE FUNCTION fASCIIr% (SEG ANY)
DECLARE SUB QCopyStr2Arr (SEG ANY, SEG ANY)
'────────────────────────────────────────────────────────────────────────
'────────── optional w/ fJustify$ ──────────────────────────────────────
'────────────────────────────────────────────────────────────────────────
DECLARE FUNCTION fJustify$ (BYVAL D$, BYVAL Length%, BYVAL Just%)
DECLARE SUB TprintCLEAR (BYVAL R?,BYVAL C?,BYVAL Cs?,BYVAL V$,BYVAL A?)
$endif
%UP_key = &h4800
%DOWN_key = &h5000
%CTRL_HOME = &h7700
%CTRL_END = &h7500
%ENTER_key = &h000D
%ESC_key = &h001B
%TAB_key = &h0009 : %SHIFT_TAB = &h0F00
%F01_key = &h3B00
%F10_key = &h4400
%ALT_X = &h2D00
'.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°
' ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° °
$if 0
PURPOSE: provide multi-field support using arrays and fTinput$
this file is an .INC file to be modified then included into
your program
PARAMS: D$() field data both in and out
T$() TinputTYPE + Mask$ for each field
S$ skip-to fields with <TAB> and <SHIFT><TAB>
CHR$(Fld1%,Fld5%,Fld7%,Fld10%) etc.
if S$ = "" then no skipping
H$() 1 line help for each field
if UBOUND( H$(1) ) = 0 then no help printed
Fld% INCOMING starting field
RETURNED last entered/exited field
RETURNS: exiting key-press of last field
%ESC_key or %ALT_X
no final checking on mandatory fields
it is assumed that the user wishes to forget all the
changes made. I query this action with important data
just to make sure before chucking it all out the window
%F10_key
final mandatory field check & will not exit if all of
them have not been filled
is is assumed that the user is feeling good about his/her
input session and that the data should be stored/saved
NOTE: %F01_key
is supported for help but you need to place the call
command in this code. .Just or .Style could be used to
determine which of the help screens to pop for explicit
field style sensitive help
NOTE: if .Just is not being used by any fields and you are not using
fJustify$ then remove the 2 lines of code that make that call
$endif
'.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°
' ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° °
FUNCTION fTinput2%( SEG D$(), SEG T$(), SEG S$, SEG H$(), SEG Fld% ) LOCAL PUBLIC
LOCAL Exet$, G%, HelpOn%, Hline$
LOCAL Last%, TabFlds%, X%, T&, S?()
DIM tINP AS TinputTYPE ' local type
Last% = UBOUND( D$(1) ) ' last field
Fld% = MIN( MAX( 1, Fld% ), Last% ) ' 1st field
HelpOn% = UBOUND( H$(1) ) ' use help?
Exet$ = CHR$(0,45,0,59,0,68,0,72,0,80,0,117,0,119) ' exit keys
TabFlds% = LEN(S$) ' # of tab flds
IF TabFlds% > 0 THEN ' use tab flds?
DIM S?(TabFlds%) ' local array
QcopySTR S$, S?(1) ' load array
Exet$ = CHR$(9,0,0,15) + Exet$ ' exit keys
END IF '
IF HelpON% > 0 THEN Hline$ = fHelpLine$( H$(Fld%), 1 ) ' set-up help
DO '
IF HelpOn% > 0 THEN fHelpLine H$(Fld%), 1 ' print help
G% = fTinput%( D$(Fld%), T$(Fld%), Exet$, 31, 113 ) ' do it!
IF G% = %ESC_key OR G% = %ALT_X THEN EXIT LOOP ' bail out
IF G% = %F01_key THEN ' Help
' PUT HELP CALL HERE ' your rtn
ITERATE ' goes here
END IF '
LSET tINP = T$(Fld%) '
IF tINP.Just > 0 THEN ' if you're not
D$(Fld%) = fJustify$( D$(Fld%), tINP.Cols, tINP.Just ) ' using this
TprintCLEAR tINP.Row, tINP.Col, tINP.Cols, D$(Fld%), 0 ' then delete
IF ( tINP.MustBe > 0 ) AND _ ' final test
( D$(Fld%) = "" ) THEN ITERATE ' final test?
END IF '
SELECT CASE G% '''''''''''''''''''''
CASE %UP_key '
DECR Fld%, 1 '
IF Fld% = 0 THEN Fld% = Last% ' prev field
CASE %DOWN_key, %ENTER_key '
INCR Fld%, 1 '
IF Fld% > Last% THEN Fld% = 1 ' next field
CASE %TAB_key '
S?(0) = S?(1) '
ARRAY SCAN S?(1) FOR TabFlds%, > Fld%, TO X% '
Fld% = S?(X%) '
CASE %SHIFT_TAB '
S?(0) = S?(TabFlds%) '
FOR X% = TabFlds% TO 1 STEP -1 ' search S?() for
IF Fld% > S?(X%) THEN EXIT FOR ' previous skip
NEXT ' field
Fld% = S?(X%) '
CASE %CTRL_HOME '
Fld% = 1 '
CASE %CTRL_END '
Fld% = Last% '
CASE %F10_key '
FOR G% = Last% TO 1 STEP -1 ' run a last check
LSET tINP = T$(G%) ' on manditory flds
IF tINP.MustBe = 0 THEN ITERATE ' not manditory
IF (D$(G%) = "" ) OR _ ' can't be null
(tINP.Style = "N") AND _ ' or ZERO if nbrs
(VAL( D$(G%) ) = 0 ) THEN EXIT FOR '
NEXT '
IF G% = 0 THEN EXIT LOOP ' all fields ok!
Fld% = G% ' get this one!
END SELECT '
LOOP '
'
IF HelpON% > 0 THEN TBoxWrite Hline$ ' restore help line
FUNCTION = G% ' return key-press
END FUNCTION