MMCC MASTHEAD
Mid-Michigan Computer Consultants - Bay City, Michigan
 


CONTENTS       (old style)
Mid-Michigan Computer Consultants
509 Center
Bay City, Michigan

Sales (989) 892-9242
Support (989) 686-8860

Plb-0330.cfm v1.0


plb-t010.cfm
 

ANSI Standard PL/B Language and Visual PL/B

FOCUS and VALIDATE

NOTE TO OUR READERS
This web resource is written for our own use. But we feel strongly that the PL/B language should be shared with the software community. So feel free to use this at will! BUT PLEASE... if you find errors or omissions or have a better way to do something. TELL US! Dialog helps us all. Send e-mail to: support@mmcctech.com
Updated Dec 15, 2001

FOCUS

FOCUS is a term used to indicate which object on a screen is currently active. If you click on a name field, that field "has the focus" until you click on something else.

Some confusion occurs concerning how and when to use focus events. Two events are generated regarding FOCUS:

GOTCHA's

The instinctive thought by most programmers is that LOSTFOCUS is the perfect time to check an object for errors. If the user clicks on SEX and enters "N", you'd want to check that and throw an error alert immediately.

The subtle problem is that when a user clicks another object Windows gives you the GOTFOCUS event on the new object BEFORE giving LOSTFOCUS for the previous object.

The difficulty, of course, is figuring out where you came from when you land on a new object. One method is to set some kind of flag to indicate where you currently are (GOTFOCUS) and then test that first on the NEXT GOTFOCUS. In pseudo code:
   GOTFOCUS event on STATE
     If I was last on NAME
         edit the name
     Else if I was last on SEX
         edit the sex
     endif
     save "STATE" as last event
     return
	 
   LOSTFOCUS event... 
     just ignore it since
     you do everything on
     the GOTFOCUS
Obviously, the above code can get rather involved if you have lots of objects on the screen. It's not a good solution.

VALIDATE

Recognizing the difficulties, Sunbelt added the psuedo event "VALIDATE" to their PL/B just for this:
NOTE: Validate is not completely automatic. Each object has a new, related property called CAUSE VALIDATE which controls validation. The idea behind CAUSE VALIDATE is this.
Being aware of CAUSE VALIDATE is important because the form designer defaults objects with this property turned OFF. If you have a VALIDATE event on any objects, be sure to insure that CAUSE VALIDATION is turn on for all other objects which you'd want to have it for.


v1.10

Write to MMCC Technical Support at:               Send e-mail to MMCC.
MMCC - Technical Support
600 W. Midland
Bay City, MI 48708
(989) 686-8860
© 1997 - 2024 MMCC - All Rights Reserved