home *** CD-ROM | disk | FTP | other *** search
- '────────────────────────────────────────────────────────────────────────────
- 'TOORDER.Bas, written by P-Screen Professional Date: 02-08-1990
-
- 'Screen (TOORDER) is in library (P-SCREEN) # of Fields: 28
- '
- ' Purpose: - 1 of 2 QuickBASIC demo programs written entirely by
- ' P-Screen Professional (PS Pro)
- ' - Demonstrates several subroutines included in PS Pro:
- ' 1. rsMinput 2. rsQprint 3. FormatUsing
- ' 4. Exist 5. ProperName 6. rsCmpRst
- '
- ' Compatibility: QuickBASIC 4.0 or higher -OR- PDS 7 !!
- ' *
- ' To run this: qb toorder /l ps-demo.qlb -OR- qbx toorder /l bc7-demo
- '
- ' Notes: - Please read Routines.Doc for details on the subroutines
- ' included with PS Pro. These routines are in ps-demo.qlb.
- ' - After PS Pro wrote this, we did some minor editing:
- ' -- added this intro
- ' -- "hardcoded" some variables, taking them out of a loop
-
- 'NOTE: Run with QB 4.0+ -OR- PDS7 with these files in your Quick Library:
- 'LoadScrn, rsLoadBin, rsCompRest, rsMinput, rsQprint, Exists, ProperName & FormatUsing
- '────────────────────────────────────────────────────────────────────────────
-
- DEFINT A-Z 'default = Integers
- CONST True = -1, False = NOT True
-
- '----Declare subroutines. MUST declare QB functions.
- DECLARE SUB rsMInput (Text$, ValidKeys$, Exit$, Format$, Length, RetCode, Hilite, Colr)
- DECLARE SUB rsQprint (Row, Column, Colr, Text$)
- DECLARE SUB rsLoadScrn (Array%(), LibName$, FileName$, Desc$, TopRow, TopCol, BotRow, BotCol, ScrnSize, ErrCode)
- DECLARE SUB rsCompRest (TopRow, BotRow, SEG Array)
- DECLARE FUNCTION FormatUsing$ (Format$, x#) 'format numbers for editing
- DECLARE FUNCTION Exists (FileName$) 'Exists = -1 if file DOES exist, 0 if it does NOT
- DECLARE FUNCTION ProperName$ (Text$) 'convert lower case text to proper
-
- '─────────────────────────────────────────────────────────────────────────────
- TYPE TypeX 'define record elements
- YourName AS STRING * 40
- YourCompany AS STRING * 40
- StreetAddress AS STRING * 40
- City AS STRING * 24
- State AS STRING * 2
- Zip AS STRING * 12
- Phone AS STRING * 16
- TodaysDate AS STRING * 8
- Quan1 AS INTEGER
- Quan2 AS INTEGER
- Quan3 AS INTEGER
- Quan4 AS INTEGER
- Quan5 AS INTEGER
- Quan6 AS INTEGER
- Quan7 AS INTEGER
- Taxable AS STRING * 1
- T1 AS DOUBLE
- T2 AS DOUBLE
- T3 AS DOUBLE
- T4 AS DOUBLE
- T5 AS DOUBLE
- T6 AS DOUBLE
- T7 AS DOUBLE
- NumPrograms AS INTEGER
- Postage AS DOUBLE
- SubTot AS DOUBLE
- SalesTax AS DOUBLE
- GrandTotal AS DOUBLE
- END TYPE
-
- DIM TOORDER AS TypeX
-
- '─────────────────────────────────────────────────────────────────────────────
-
- '--- Alpha$ and Field Types govern which keys are considered 'Valid' by rsMInput
-
- Alpha$ = " 1234567890-+.$%QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm=!@#^&*()_[]\{}|;':,/<>?`~" + CHR$(34)
-
- '─────────────────────────────────────────────────────────────────────────────
-
- GOSUB EditTOORDER 'get to work
-
- END
- '─────────────────────────────────────────────────────────────────────────────
- EditTOORDER: 'this is what you came for
- '─────────────────────────────────────────────────────────────────────────────
-
- '----- Start by displaying our screen
-
- CONST LibName$ = "P-SCREEN"
- ScreenName$ = "TOORDER": GOSUB DisplayScreen
-
- '─────────────────────────────────────────────────────────────────────────────
- '----- Edit
-
- FieldNum = 1 'there are 28 fields, some may be calculated
- DO 'EACH LOOP: initialize RetCode, Exit$, & Format$
-
- RetCode = 32 '32 = pad with Chr$(32) -32 = Upper Case
- Exit$ = "HP;C" 'H = Up Cursor, P = Down Cursor, ; = F1 Help, C = F9 Calc
- Format$ = "" 'assume no mask--unformatted field
- Minimum$ = "" 'assume no minimum/maximum
- Maximum$ = ""
- ScreenName$ = "" 'assume no help lib/screen
- PropName = False 'assume we don't ProperName it
- ValidKeys$ = Alpha$ 'assume any character is valid
-
- SELECT CASE FieldNum
- CASE 1
- Row = 3: Column = 5: Length = 40
- PropName = True 'Later, convert to Proper Name format
- Text$ = TOORDER.YourName
- ScreenName$ = "InvToFld"
- CASE 2
- Row = 4: Column = 5: Length = 40
- PropName = True 'Later, convert to Proper Name format
- Text$ = TOORDER.YourCompany
- ScreenName$ = "InvToFld"
- CASE 3
- Row = 5: Column = 5: Length = 40
- PropName = True 'Later, convert to Proper Name format
- Text$ = TOORDER.StreetAddress
- ScreenName$ = "InvToFld"
- CASE 4
- Row = 6: Column = 5: Length = 24
- PropName = True 'Later, convert to Proper Name format
- Text$ = TOORDER.City
- ScreenName$ = "InvToFld"
- CASE 5
- Row = 6: Column = 30: Length = 2
- RetCode = -32 'turn on Upper Case
- Text$ = TOORDER.State
- CASE 6
- Row = 6: Column = 33: Length = 12
- ValidKeys$ = MID$(Alpha$, 1, 14) '0-9 Only -- plus .$-+
- Format$ = "##### - ####"
- Text$ = TOORDER.Zip
- ScreenName$ = "InvFormt"
- CASE 7
- Row = 7: Column = 12: Length = 16
- ValidKeys$ = MID$(Alpha$, 1, 14) '0-9 Only -- plus .$-+
- Format$ = "(###) ### - ####"
- GOSUB ConvertNumber
- RSET Text$ = LTRIM$(TOORDER.Phone)
- ScreenName$ = "InvFormt"
- CASE 8
- Row = 7: Column = 37: Length = 8
- ValidKeys$ = MID$(Alpha$, 1, 14) '0-9 Only -- plus .$-+
- Format$ = "##/##/##"
- Text$ = TOORDER.TodaysDate
- ScreenName$ = "InvFormt"
- CASE 9
- Row = 10: Column = 52: Length = 2
- ValidKeys$ = MID$(Alpha$, 1, 14) '0-9 Only -- plus .$-+
- GOSUB ConvertNumber
- x# = TOORDER.Quan1
- '---No Format/Mask found. Using the following::
- RSET Text$ = FormatUsing$(STRING$(Length, "#"), x#)
- Format$ = "" 'don't confuse rsMinput w/ a mask
- CASE 10
- Row = 11: Column = 52: Length = 2
- ValidKeys$ = MID$(Alpha$, 1, 14) '0-9 Only -- plus .$-+
- GOSUB ConvertNumber
- x# = TOORDER.Quan2
- '---No Format/Mask found. Using the following::
- RSET Text$ = FormatUsing$(STRING$(Length, "#"), x#)
- Format$ = "" 'don't confuse rsMinput w/ a mask
- CASE 11
- Row = 12: Column = 52: Length = 2
- ValidKeys$ = MID$(Alpha$, 1, 14) '0-9 Only -- plus .$-+
- GOSUB ConvertNumber
- x# = TOORDER.Quan3
- '---No Format/Mask found. Using the following::
- RSET Text$ = FormatUsing$(STRING$(Length, "#"), x#)
- Format$ = "" 'don't confuse rsMinput w/ a mask
- CASE 12
- Row = 13: Column = 52: Length = 2
- ValidKeys$ = MID$(Alpha$, 1, 14) '0-9 Only -- plus .$-+
- GOSUB ConvertNumber
- x# = TOORDER.Quan4
- '---No Format/Mask found. Using the following::
- RSET Text$ = FormatUsing$(STRING$(Length, "#"), x#)
- Format$ = "" 'don't confuse rsMinput w/ a mask
- CASE 13
- Row = 14: Column = 52: Length = 2
- ValidKeys$ = MID$(Alpha$, 1, 14) '0-9 Only -- plus .$-+
- GOSUB ConvertNumber
- x# = TOORDER.Quan5
- '---No Format/Mask found. Using the following::
- RSET Text$ = FormatUsing$(STRING$(Length, "#"), x#)
- Format$ = "" 'don't confuse rsMinput w/ a mask
- CASE 14
- Row = 15: Column = 52: Length = 2
- ValidKeys$ = MID$(Alpha$, 1, 14) '0-9 Only -- plus .$-+
- GOSUB ConvertNumber
- x# = TOORDER.Quan6
- '---No Format/Mask found. Using the following::
- RSET Text$ = FormatUsing$(STRING$(Length, "#"), x#)
- Format$ = "" 'don't confuse rsMinput w/ a mask
- CASE 15
- Row = 16: Column = 52: Length = 2
- ValidKeys$ = MID$(Alpha$, 1, 14) '0-9 Only -- plus .$-+
- GOSUB ConvertNumber
- x# = TOORDER.Quan7
- '---No Format/Mask found. Using the following::
- RSET Text$ = FormatUsing$(STRING$(Length, "#"), x#)
- Format$ = "" 'don't confuse rsMinput w/ a mask
- CASE 16
- Row = 20: Column = 43: Length = 1
- RetCode = -32 'turn on Upper Case
- Text$ = TOORDER.Taxable
- Minimum$ = "N"
- Maximum$ = "Y"
- ScreenName$ = "InvTxBle"
- END SELECT
-
- LOCATE Row, Column
-
- '---get color at this row/column; rsMinput takes 2 colors (Hilite, Colr to Restore)
-
- GOSUB GetColor
-
- '---use rsMinput or your own editing routine
-
- CALL rsMInput(Text$, ValidKeys$, Exit$, Format$, Length, RetCode, Hilite, Colr)
-
- '---If PropName is 'True,' reformat & reprint our text
- IF PropName THEN Text$ = ProperName$(Text$): CALL rsQprint(Row, Column, Colr, Text$)
-
-
- IF RetCode = -27 THEN EXIT DO 'Esc pressed, exit
-
- GOSUB Validate 'validate against range you specified
-
- IF Invalid AND RetCode% <> 3 THEN
- BEEP
- ELSE
- SELECT CASE RetCode 'RetCode = position in Exit$
- '1 = Up Cursor, 2 = Down Cursor, 3 = F1 Help, 4 = F9 Calc
- CASE 1 'UP cursor
- FieldNum = FieldNum - 1: IF FieldNum < 1 THEN FieldNum = 16
- CASE 3 'F1 Help
- GOSUB DisplayScreen 'display help screen. Beep = Error
- CASE 4 'F9 Calc
- GOSUB DoCalcs 'calculate your formulas, print results
- CASE ELSE 'move forward on <cr> or DOWN cursor
- FieldNum = FieldNum + 1
- IF FieldNum > 16 THEN GOSUB DoCalcs: FieldNum = 1
- END SELECT
- END IF
-
- LOOP UNTIL RetCode = -27 'exit on Esc
-
- RETURN
-
- '─────────────────────────────────────────────────────────────────────────────
- GetColor: 'get colors at this Row, Column
- '─────────────────────────────────────────────────────────────────────────────
- IF Row < 1 OR Column < 1 THEN 'avoid Illegal Function Call
- BEEP: Colr = 7: Hilite = 112: RETURN
- END IF
-
- Colr = SCREEN(Row, Column, -1) 'get color at this Row/Column
-
- Fore = (Colr MOD 16): Back = (((Colr - Fore) / 16) MOD 128)
- Hilite = (Fore AND 7) * 16 + Back + (Back AND 16) * 7
- 'reverse color for editing
-
- RETURN
-
- '─────────────────────────────────────────────────────────────────────────────
- DisplayScreen: 'Display MAIN and HELP Screens
- '─────────────────────────────────────────────────────────────────────────────
- IF LibName$ = "" OR ScreenName$ = "" THEN BEEP: RETURN
-
- IF Exists(LibName$ + ".PSL") AND RTRIM$(ScreenName$) > "" THEN
- REDIM Array%(1) 'initialize INTEGER screen array
- CALL rsLoadScrn(Array%(), LibName$, ScreenName$, Desc$, TopRow, TopCol, BotRow, BotCol, x, ErrCode)
- ELSE ErrCode = -1
- END IF
-
- IF ErrCode < 1 THEN BEEP: RETURN 'must have been an error
-
- CALL CompRestPLUS(TopRow, TopCol, BotRow, BotCol, SEG Array%(1)): ERASE Array
-
- RETURN
-
- '─────────────────────────────────────────────────────────────────────────────
- Validate: 'Validate input against ranges you specified
- '─────────────────────────────────────────────────────────────────────────────
-
- Text$ = RTRIM$(Text$)
-
- Invalid = 0 'assume it's valid
-
- IF LEN(Minimum$) AND LEN(Maximum$) THEN
- SELECT CASE FieldNum
-
- CASE 1, 2, 3, 4, 5, 16 'it's a Text field
-
- IF Text$ < Minimum$ OR Text$ > Maximum$ THEN Invalid = True
-
-
- CASE ELSE 'it's a Numeric field
-
- '--- VAL produces 'Type Mismatch' error if 1st character is %, etc. -- Print Using error
- FOR x = 1 TO LEN(Text$) 'if not numeric, change to space
- y = ASC(MID$(Text$, x, 1)): IF y < 42 OR y > 57 THEN MID$(Text$, x, 1) = CHR$(32)
- NEXT
-
- x# = VAL(Text$)
- IF x# < VAL(Minimum$) OR x# > VAL(Maximum$) THEN Invalid = True
- END SELECT
- END IF
-
- IF Invalid THEN RETURN 'If it's invalid, don't assign
-
- SELECT CASE FieldNum
- CASE 1: TOORDER.YourName = Text$
- CASE 2: TOORDER.YourCompany = Text$
- CASE 3: TOORDER.StreetAddress = Text$
- CASE 4: TOORDER.City = Text$
- CASE 5: TOORDER.State = Text$
- CASE 6: TOORDER.Zip = Text$
- CASE 7: TOORDER.Phone = Text$
- CASE 8: TOORDER.TodaysDate = Text$
- CASE 9: TOORDER.Quan1 = VAL(Text$)
- CASE 10: TOORDER.Quan2 = VAL(Text$)
- CASE 11: TOORDER.Quan3 = VAL(Text$)
- CASE 12: TOORDER.Quan4 = VAL(Text$)
- CASE 13: TOORDER.Quan5 = VAL(Text$)
- CASE 14: TOORDER.Quan6 = VAL(Text$)
- CASE 15: TOORDER.Quan7 = VAL(Text$)
- CASE 16: TOORDER.Taxable = Text$
- END SELECT
-
- RETURN
-
- '─────────────────────────────────────────────────────────────────────────────
- ConvertNumber: 'set length of Text$ equal to # of valid positions in mask; inc. '.'
- '─────────────────────────────────────────────────────────────────────────────
- IF LEN(Format$) < 1 THEN Text$ = SPACE$(Length): RETURN
-
- NumberSpaces = 0
- FOR x = 1 TO LEN(Format$)
- IF INSTR("#·.", MID$(Format$, x, 1)) THEN NumberSpaces = NumberSpaces + 1
- NEXT
- Text$ = SPACE$(NumberSpaces)
-
- RETURN
-
- '─────────────────────────────────────────────────────────────────────────────
- DoCalcs: 'Do calculations. Delete this if none.
- '─────────────────────────────────────────────────────────────────────────────
-
- '---Calculate: TOORDER.T1
- TOORDER.T1 = TOORDER.Quan1 * 49
- Row = 10: Column = 68: Length = 11
- x# = TOORDER.T1 'FormatUsing needs DOUBLE Prec.
- Temp$ = SPACE$(Length)
- RSET Temp$ = FormatUsing$("$######,.##", x#) 'RSet to allign decimals, etc.
-
- GOSUB PrintResults
-
- '---Calculate: TOORDER.T2
- TOORDER.T2 = TOORDER.Quan2 * 29
- Row = 11: Column = 68: Length = 11
- x# = TOORDER.T2 'FormatUsing needs DOUBLE Prec.
- Temp$ = SPACE$(Length)
- RSET Temp$ = FormatUsing$("$######,.##", x#) 'RSet to allign decimals, etc.
-
- GOSUB PrintResults
-
- '---Calculate: TOORDER.T3
- TOORDER.T3 = TOORDER.Quan3 * 79
- Row = 12: Column = 68: Length = 11
- x# = TOORDER.T3 'FormatUsing needs DOUBLE Prec.
- Temp$ = SPACE$(Length)
- RSET Temp$ = FormatUsing$("$######,.##", x#) 'RSet to allign decimals, etc.
-
- GOSUB PrintResults
-
- '---Calculate: TOORDER.T4
- TOORDER.T4 = TOORDER.Quan4 * 49
- Row = 13: Column = 68: Length = 11
- x# = TOORDER.T4 'FormatUsing needs DOUBLE Prec.
- Temp$ = SPACE$(Length)
- RSET Temp$ = FormatUsing$("$######,.##", x#) 'RSet to allign decimals, etc.
-
- GOSUB PrintResults
-
- '---Calculate: TOORDER.T5
- TOORDER.T5 = TOORDER.Quan5 * 49
- Row = 14: Column = 68: Length = 11
- x# = TOORDER.T5 'FormatUsing needs DOUBLE Prec.
- Temp$ = SPACE$(Length)
- RSET Temp$ = FormatUsing$("$######,.##", x#) 'RSet to allign decimals, etc.
-
- GOSUB PrintResults
-
- '---Calculate: TOORDER.T6
- TOORDER.T6 = TOORDER.Quan6 * 39
- Row = 15: Column = 68: Length = 11
- x# = TOORDER.T6 'FormatUsing needs DOUBLE Prec.
- Temp$ = SPACE$(Length)
- RSET Temp$ = FormatUsing$("$######,.##", x#) 'RSet to allign decimals, etc.
-
- GOSUB PrintResults
-
- '---Calculate: TOORDER.T7
- TOORDER.T7 = TOORDER.Quan7 * 29
- Row = 16: Column = 68: Length = 11
- x# = TOORDER.T7 'FormatUsing needs DOUBLE Prec.
- Temp$ = SPACE$(Length)
- RSET Temp$ = FormatUsing$("$######,.##", x#) 'RSet to allign decimals, etc.
-
- GOSUB PrintResults
-
- '---Calculate: TOORDER.NumPrograms
- TOORDER.NumPrograms = TOORDER.Quan1 + TOORDER.Quan2 + TOORDER.Quan3 + TOORDER.Quan4 + TOORDER.Quan5 + TOORDER.Quan6 + TOORDER.Quan7
- Row = 18: Column = 50: Length = 4
- x# = TOORDER.NumPrograms 'FormatUsing needs DOUBLE Prec.
- Temp$ = SPACE$(Length)
- RSET Temp$ = FormatUsing$("####", x#) 'RSet to allign decimals, etc.
-
- GOSUB PrintResults
-
- '---Calculate: TOORDER.Postage
- TOORDER.Postage = TOORDER.NumPrograms * 3
- Row = 18: Column = 66: Length = 13
- x# = TOORDER.Postage 'FormatUsing needs DOUBLE Prec.
- Temp$ = SPACE$(Length)
- RSET Temp$ = FormatUsing$("$########,.##", x#)'RSet to allign decimals, etc.
-
- GOSUB PrintResults
-
- '---Calculate: TOORDER.SubTot
- TOORDER.SubTot = TOORDER.T1 + TOORDER.T2 + TOORDER.T3 + TOORDER.T4 + TOORDER.T5 + TOORDER.T6 + TOORDER.T7 + TOORDER.Postage
- Row = 19: Column = 66: Length = 13
- x# = TOORDER.SubTot 'FormatUsing needs DOUBLE Prec.
- Temp$ = SPACE$(Length)
- RSET Temp$ = FormatUsing$("$########,.##", x#)'RSet to allign decimals, etc.
-
- GOSUB PrintResults
-
- '---Calculate: TOORDER.SalesTax
- TOORDER.SalesTax = (TOORDER.SubTot * .065) * INSTR("Y", TOORDER.Taxable)
- Row = 20: Column = 66: Length = 13
- x# = TOORDER.SalesTax 'FormatUsing needs DOUBLE Prec.
- Temp$ = SPACE$(Length)
- RSET Temp$ = FormatUsing$("$########,.##", x#)'RSet to allign decimals, etc.
-
- GOSUB PrintResults
-
- '---Calculate: TOORDER.GrandTotal
- TOORDER.GrandTotal = TOORDER.SubTot + TOORDER.SalesTax
- Row = 21: Column = 66: Length = 13
- x# = TOORDER.GrandTotal 'FormatUsing needs DOUBLE Prec.
- Temp$ = SPACE$(Length)
- RSET Temp$ = FormatUsing$("$########,.##", x#)'RSet to allign decimals, etc.
-
- GOSUB PrintResults
-
- RETURN
- '─────────────────────────────────────────────────────────────────────────────
- PrintResults: 'get color and print calculated results
- 'a separate routine eliminates one CALL per calculation
- '─────────────────────────────────────────────────────────────────────────────
- GOSUB GetColor: CALL rsQprint(Row, Column, Colr, Temp$)
-
- RETURN
-
-