Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Force 4.0 Reference - activategetpreblock() activate a pre-get function http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 activategetpreblock() Activate a pre-get function
------------------------------------------------------------------------------
 Declaration
   io.hdr

 Syntax
   proc activategetpreblock extern
   param untyped xProc

 Arguments
   xProc is the procedure to be called when entering a get field.

 Return
   None.

 Description
   activategetpreblock() hooks the xProc user-defined procedure to the
   get/read system. The UDF is used to determine if a specific get field
   can be edited. It is also possible to use the UDF to present a
   field-specific help message.

   Whenever the user positions the cursor into a get field, the UDF is called
   with the get-id of the new field passed as a uint parameter. The UDF must
   return a logical value. If the return value is .t., editing of the field
   is allowed, otherwise it will be skipped.

   The installed xProc remains in effect and has control over all
   gets until you deactivate it by calling the procedure
   deactivategetpreblock(), or by installing another xProc by calling
   activategetpreblock() again.

 Example
   #define EXAMPLE_IO
   #include example.hdr

   vardef static
      char( 10 ) cField1 := "          "
      char( 10 ) cField2 := "          "
      char( 10 ) cField3 := "          "
   enddef
   
   // This function disables field 2 for entry
   //
   func logical DisableGet2
   param value uint uId
   return( uId <> 2 )
   endfunc
   
   // This function provides a field-sensitive help message
   //
   func logical ShowFieldHelp
   param value uint uId
   do case
   case uId == 1
      @ 12, 0 say "This is field 1"
   case uId == 2
      @ 12, 0 say "This is field 2"
   case uId == 3
      @ 12, 0 say "This is field 3"
   endcase
   return( .t. )
   endfunc
   
   proc Test_activategetpreblock
   clear
   
   @ 1, 0 ?? "Field 2 disabled"
   activategetpreblock( DisableGet2 )
   @ 3,0 get cField1
   @ 5,0 get cField2
   @ 7,0 get cField3
   read
   
   @ 1, 0 ?? "Field help active"
   activategetpreblock( ShowFieldHelp )
   @ 3,0 get cField1
   @ 5,0 get cField2
   @ 7,0 get cField3
   read
   @ 12, 0 say "               "
   
   deactivategetpreblock()
   
   @ 1, 0 ?? "No pre-get block active"
   @ 3,0 get cField1
   @ 5,0 get cField2
   @ 7,0 get cField3
   read
   endproc

   proc main
   Test_activategetpreblock()
   endproc

See Also: deactivategetpreblock() get

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson