home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a012 / 1.ddi / CHAP26.EXE / CHP2615.PRG < prev    next >
Encoding:
Text File  |  1991-04-30  |  1.9 KB  |  73 lines

  1. /*
  2.    Listing 26.15 @..MESSAGE with cargo/reader instance variables
  3.    Author: Greg Lief
  4.    Excerpted from "Clipper 5: A Developer's Guide"
  5.    Copyright (c) 1991 M&T Books
  6.                       501 Galveston Drive
  7.                       Redwood City, CA 94063-4728
  8.                       (415) 366-3600
  9. */
  10.  
  11. //───── NOTE: must compile with the /N option!
  12.  
  13. #command @ <row>, <col> GET <var> [PICTURE <pic>] ;
  14.          [VALID <valid>] [WHEN <when>] ;
  15.          [MESSAGE <message>] => ;
  16.             SetPos(<row>, <col>) ; ;
  17.             AAdd( GetList, _GET_(<var>, <(var)>, <pic>, ;
  18.                   <{valid}>, <{when}>) ) ; ;
  19.             Atail(getlist):reader := { | g | MyReader(g) } ;
  20.             [; Atail(getlist):cargo := <message> ]
  21.  
  22. #include "getexit.ch"
  23.  
  24. function test
  25. local x := 0, y := 1, getlist := {}
  26. set message to maxrow()
  27. cls
  28. @ 20,0 get x message "This is the first GET"
  29. @ 21,0 get y
  30. read
  31. return nil
  32.  
  33. /*
  34.      MyReader()
  35.      Alternate modal read of a single GET.
  36. */
  37. function MyReader( get )
  38. local mess_row
  39. // read the GET if the WHEN condition is satisfied
  40. if ( GetPreValidate(get) )
  41.    // activate the GET for reading
  42.    mess_row := set(_SET_MESSAGE)
  43.    if ! empty(get:cargo)
  44.       @ mess_row, 0 say padc( get:cargo, maxcol() + 1)
  45.    else
  46.       scroll(mess_row, 0, mess_row, maxcol(), 0)
  47.    endif
  48.    get:SetFocus()
  49.    do while ( get:exitState == GE_NOEXIT )
  50.       // check for initial typeout (no editable positions)
  51.       if ( get:typeOut )
  52.          get:exitState := GE_ENTER
  53.       endif
  54.  
  55.       // apply keystrokes until exit
  56.       do while ( get:exitState == GE_NOEXIT )
  57.          GetApplyKey( get, Inkey(0) )
  58.       enddo
  59.  
  60.       // disallow exit if VALID condition is not satisfied
  61.       if ( !GetPostValidate(get) )
  62.          get:exitState := GE_NOEXIT
  63.       endif
  64.    enddo
  65.  
  66.    // de-activate the GET
  67.    get:KillFocus()
  68.  
  69. endif
  70. return nil
  71.  
  72. // end of file CHP2615.PRG
  73.