home *** CD-ROM | disk | FTP | other *** search
- ***************************************************************************
- ** ONFIELD.PRG
- ** (C) Copyright 1990-92, Sub Rosa Publishing Inc.
- **
- ** A demonstration program provided to VP-Info users.
- ** This program may be copied freely. If it is used in commercial code,
- ** please credit the source, Sub Rosa Publishing Inc.
- **
- ** ONFIELD demonstrates the use of the ON FIELD command along with
- ** a variety of Info commands and functions.
- ** ONFIELD is compatible with all current versions of VP-Info.
- **
- ** The ON FIELD/ENDON structure is unique to VP-Info.
- ** It is hoped that this sample program will help illustrate how
- ** this strucure can be used.
- **
- ** Many application have the following steps in common:
- ** i) Accept input information - often by the screenful.
- ** ii) Validate the information - requesting additional or corrected
- ** information as required.
- ** iii) Process the information.
- ** iv) Report the results.
- **
- ** Using the ON FIELD/ENDON structure combines steps i and ii in a very
- ** natural way, allowing field by field verification as information
- ** is entered.
- **
- ** Input fields can defined by a series of @ x,y get statements, or by
- ** a 'painted' screen using the TEXT/ENDTEXT structure, or even
- ** a combination of the two. VP-Info creats an internal GET TABLE
- ** listing all active input fields. Input is activated by a READ
- ** command. If there is an ON FIELD/ENDON structure before the READ
- ** statement, it is referanced as part of the READ process.
- **
- ** The GET TABLE consists of entries numbered 0 to 65. Fields 1 to 64 refer
- ** to the actual input fields. Field 0 refers to a set of preprocessing
- ** commands, while field 65 refers to a set of post-processing commands.
- **
- ** Sid Bursten and Bernie Melman
- ***************************************************************************
- * initialize variables
- CUSTCODE = blank(8)
- UNIT_WT = 5.65
- MIN_WT = 5.4
- MAX_WT = 5.85
- UNITS_SOLD = 0.0
- NET_WT = 0
- UNIT_PRICE = 6.48
- MIN_PRICE = 5.50
- MAX_PRICE = 8.00
- NET_PRICE = 0
- *
- IF :color<> 7 ; choose a color if not monochrome
- SET color to 126 ; yellow on grey
- ENDIF
- ERASE; clears screen
- WINDOW 5,10,18,72 DOUBLE ; note no ',' before keyword DOUBLE
- * 'paint' text screen.
- TEXT
- .. custcode !!!!!!!!
- .. unit_wt 99.999
- .. units_sold 999
- .. net_wt 99999.999
- .. unit_price 999.99
- .. net_price 99999.99
- .. min_price $$9.99
- .. max_price $$9.99
- .. min_wt 999.99
- .. max_wt 999.99
-
- WIDGETS OF THE WORLD
- ORDER SUMMARY DEMO PROGRAM
- (Experiment with illegal values)
-
- UNITS SOLD: @units_sold CUSTOMER CODE: @custcode
- MINIMUM MAXIMUM ACTUAL
- UNIT WEIGHT: #min_wt #max_wt @unit_wt
- UNIT PRICE: #min_price #max_price @unit_price
-
- NET WEIGHT: @net_wt
- NET PRICE: @net_price
-
- ENDTEXT
- * declare the ON FIELD structure AFTER the input screen is displayed
- * but BEFORE the READ statemet that it controls
- ON field
- FIELD 0 ; field 0 commands are executed before an real field is processed
- @ 19,22 say ' Enter QUIT to exit '
- :FIELD = field(custcode)
- FIELD custcode
- * customer code could be verified here - and customer file alligned
- IF custcode = 'QUIT'
- :FIELD = 65 ; i.e. fall out of the READ
- ELSE
- @ 19,22 say blank(38,205) ; rebuild double box
- @ 19,22 say ' Enter Negative Value to Exit. '
- :FIELD = field(units_sold)
- ENDIF
- FIELD units_sold
- DO CASE
- CASE units_sold < 0 ; user wants out
- :FIELD = 65
- CASE units_sold > 300
- RING
- RING
- @ 19,22 say blank(38,205) ; rebuild double box
- @ 19,22 say " I won't believe more than 300 !!! "
- :FIELD = field(units_sold)
- CASE units_sold >=0 .and. units_sold < 20
- RING
- @ 19,22 say blank(38,205) ; rebuild double box
- @ 19,22 say ' Oh! Dissapointing sales volume !!! '
- :FIELD = field(unit_wt)
- CASE units_sold > 50 .and. units_sold < 300
- ?? chr(7) ; RING does the same thing as this line
- @ 19,22 say blank(38,205) ; rebuild double box
- @ 19,22 say ' Hey, Good Work !!! '
- :FIELD = field(unit_wt)
- OTHERWISE
- @ 19,22 say blank(38,205)
- :FIELD = field(unit_wt)
- ENDCASE
- FIELD unit_wt
- IF unit_wt < min_wt .or. unit_wt > max_wt
- ?? chr(7),chr(7)
- @ 19,22 say blank(38,205) ; rebuild double box
- @ 19,22 say ' Oops, weight out of range! '
- :FIELD = field(unit_wt)
- ELSE
- NET_WT = unit_wt * units_sold
- :FIELD = field(unit_price)
- @ 19,22 say blank(38,205) ; rebuild double box
- ENDIF
- FIELD unit_price
- IF unit_price < min_price .or. unit_price > max_price
- RING
- RING
- @ 19,22 say blank(38,205) ; rebuild double box
- @ 19,22 say ' Oops, price out of range! '
- :FIELD = field(unit_price)
- ELSE
- NET_PRICE = unit_price * units_sold
- :FIELD = 65
- ENDIF
- FIELD 65
- RING
- @ 19,22 say blank(38,205) ; rebuild double box
- @ 19,22 say ' Press any key to end demo. '
- ENDON
- READ
- DUMMY = inkey()
- WINDOW
- chain samples*
- * *** end of ONFIELD.PRG ***