Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Controls, Events, Commands, and More : Page 2

Dive right in to Visual FoxPro 9.0's new properties, events, and methods; new or improved commands; and FoxPro Foundation Classes (FFCs).


advertisement
NewObject() Creates Objects without Raising Initialization Code
The NewObject function now accepts 0 as the third parameter in order to create the object without raising code in the Init method. That's useful when the interface of an object must be analyzed (using the AMember function, for example), where neither the code on the Init or Destroy methods should run.

When the following code snippet runs, you'll notice that the Customer table doesn't open when the Init method fires:

loCustomer = NewObject("CustomerBizObj",; "NewObjectSample.prg", 0) AMembers(laMembers, loCustomer, 1) Display Memory like laMembers Define Class CustomerBizObj As Session CustomerID = "" CustomerName = "" Procedure Init Use Home(1)+"\samples\northwind\Customers" EndProc Procedure GetCustomersByPk(lcPK As String) EndProc EndDefine

Set Path Command Enhancements
An Additive clause was added to the Set Path command. When that clause is used, the specified path is added to the path setting, if it isn't there already. Besides that, the Set Path command's maximum character limit has been increased to 4095 characters.

AppState Property Detects an Application Losing or Receiving Focus
The _Screen object has a new property called AppState. This property is read-only and available only at runtime. It indicates whether the Visual FoxPro application has focus (value 1), or not (value 0). The value changes automatically whenever the application loses or receives focus, such as when the user uses Alt+Tab. A Timer object, or event handler (using the BindEvent function) can be used to query this property and execute code whenever its value changes.

Specify Where Focus is Assigned in the Valid Event
It's always been a pain when something happens inside a Valid event and you want the focus to go to another control, as calling SetFocus from within a Valid event is not allowed. That's been solved in Visual FoxPro 9 by allowing you to return the execution to a specified object from within the Valid event:

Return Thisform.txtCity

ICASE() Function
The IIF() (immediate if) function has always been very useful, but the more complex the expressions it contains, the harder it is to read the code, particularly when multiple IIF calls are needed. The ICASE (immediate case) function solves that problem. The following code snippet shows an example written using both the IIF and the ICASE functions:



Local lcAnswer lcAnswer = "YES" ? Iif(lcAnswer = "YES", "answered 'yes'",; Iif(lcAnswer = "NO", "answered 'no'",; 'unanswered')) ? ICASE(lcAnswer = "YES", "answered 'yes'",; lcAnswer = "NO", "answered 'no'",; "unanswered")

TTOC() Converts DateTime Expressions to XML DateTime Format
Visual FoxPro 9 joins the ranks of great software XML adopters. The TTOC function has been improved and receives a value of 3 as the second parameter, indicating that the resulting string must be formatted as an XML DataTime format.

? Ttoc(Datetime(),3)

The settings Set Century, Set Hours, or Set Seconds don't affect the result of the TTOC function when the parameter 3 is passed.



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date