home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a054 / 1.img / GETPRGS.EXE / GETS04.PRG < prev    next >
Encoding:
Text File  |  1992-03-01  |  1.6 KB  |  55 lines

  1.     // Gets04.prg
  2.     //
  3.     // Simple when example handling problem, no hard coding of array
  4.     // indeces, handling say text
  5.  
  6.     MEMVAR GetList
  7.  
  8.     #xtranslate GET_NUMBER(<cName>)                                  ;
  9.                 =>                                                   ;
  10.                 Ascan(GetList, {|o| Trim(Upper(o:name)) == <cName>}) 
  11.  
  12.     #xtranslate GET_NUMBER(<cName>, <gl>)                            ;
  13.                 =>                                                   ;
  14.                 Ascan(<gl>, {|o| Trim(Upper(o:name)) == <cName>})
  15.  
  16.     // Indexes into discount object's cargo array
  17.     #define SAY_ROW  1
  18.     #define SAY_COL  2
  19.     #define SAY_TEXT 3
  20.  
  21.     FUNCTION Gets04
  22.  
  23.     LOCAL nQty := 0
  24.     LOCAL nDiscount := 0
  25.     LOCAL nAccount  := 0
  26.  
  27.       CLEAR SCREEN
  28.       @ 10, 10 SAY "Enter Quantity" GET nQty ;
  29.                VALID {|oGet| ResetQty(oGet, GetList), .T.}
  30.       @ 11, 25 GET nDiscount WHEN nQty > 10 ;
  31.            SEND cargo := {11, 10, "Enter Discount"}
  32.       @ 12, 10 SAY " Enter A / C #" GET nAccount
  33.       READ
  34.  
  35.     RETURN NIL
  36.  
  37.  
  38.     FUNCTION ResetQty(oGet, GetList)
  39.  
  40.     LOCAL nDiscGet := GET_NUMBER("NDISCOUNT")
  41.  
  42.     LOCAL oDiscGet := GetList[nDiscGet]
  43.  
  44.       IF oGet:varGet() <= 10
  45.         oDiscGet:varPut(0)
  46.         oDiscGet:display()
  47.         @ oDiscGet:cargo[SAY_ROW], oDiscGet:cargo[SAY_COL] ;
  48.           SAY Space(Len(oDiscGet:cargo[SAY_TEXT]))
  49.       ELSE
  50.         @ oDiscGet:cargo[SAY_ROW], oDiscGet:cargo[SAY_COL] ;
  51.           SAY oDiscGet:cargo[SAY_TEXT]
  52.       ENDIF
  53.  
  54.     RETURN NIL
  55.