home *** CD-ROM | disk | FTP | other *** search
- // Gets04.prg
- //
- // Simple when example handling problem, no hard coding of array
- // indeces, handling say text
-
- MEMVAR GetList
-
- #xtranslate GET_NUMBER(<cName>) ;
- => ;
- Ascan(GetList, {|o| Trim(Upper(o:name)) == <cName>})
-
- #xtranslate GET_NUMBER(<cName>, <gl>) ;
- => ;
- Ascan(<gl>, {|o| Trim(Upper(o:name)) == <cName>})
-
- // Indexes into discount object's cargo array
- #define SAY_ROW 1
- #define SAY_COL 2
- #define SAY_TEXT 3
-
- FUNCTION Gets04
-
- LOCAL nQty := 0
- LOCAL nDiscount := 0
- LOCAL nAccount := 0
-
- CLEAR SCREEN
- @ 10, 10 SAY "Enter Quantity" GET nQty ;
- VALID {|oGet| ResetQty(oGet, GetList), .T.}
- @ 11, 25 GET nDiscount WHEN nQty > 10 ;
- SEND cargo := {11, 10, "Enter Discount"}
- @ 12, 10 SAY " Enter A / C #" GET nAccount
- READ
-
- RETURN NIL
-
-
- FUNCTION ResetQty(oGet, GetList)
-
- LOCAL nDiscGet := GET_NUMBER("NDISCOUNT")
-
- LOCAL oDiscGet := GetList[nDiscGet]
-
- IF oGet:varGet() <= 10
- oDiscGet:varPut(0)
- oDiscGet:display()
- @ oDiscGet:cargo[SAY_ROW], oDiscGet:cargo[SAY_COL] ;
- SAY Space(Len(oDiscGet:cargo[SAY_TEXT]))
- ELSE
- @ oDiscGet:cargo[SAY_ROW], oDiscGet:cargo[SAY_COL] ;
- SAY oDiscGet:cargo[SAY_TEXT]
- ENDIF
-
- RETURN NIL