` Better OOP part 6 (Dan Pressnell) - Icetips Article
Icetips - Templates, Tools & Utilities for Clarion Developers

Templates, Tools and Utilities
for Clarion Developers

Icetips Article

Back to article list   Search Articles     Add Comment     Printer friendly     Direct link  

OOP: Better OOP part 6
2003-04-23 -- Dan Pressnell
 
Newsgroups: comp.lang.clarion,topspeed.topic.oop March 5, 2006: Note that the code is now available at: http://www.icetips.com/downloadfile.php?FileID=59 If you've downloaded the sample OOP app from http://toolwares.com/oop_sample.ZIP, download it again, because I've added more to it. In the sample app, I'm using a Microsoft Access database. In the class methods that retrieve the data, I use a variation of one technique that I described in my SQL articles, so it might look a little strange to have a Clarion program getting data that way. If you prefer, you can use Clarion's file structures with VIEWs and ABC file access. Look at the new procedure ShowTeamsWithView. That procedure looks almost identical to the ShowTeams procedure. Neither give any indication of how the data is retrieved from the database. The ShowTeamsWithView procedure instantiates the TeamsClass2Type class, though. That class uses a VIEW and the ABC RelationManager, as you can see in the class by looking in the Classes:1 "procedure." In the TeamsClass2Type.Getdata method, a view is declared, the ABC RelationManager is opened for a file, a buffer for the view is set, the sort order of records retrieved is specified, and the data is loaded into a queue. Then the VIEW and the RelationManager is closed. There is an additional call to a method in the class to calculate the total of the TeamID field in the records. While you will rarely have to caculate the sum of ID fields, it serves as an example of what I call post-query processing. That is, after the query, you have additional work to do on the retrieved data, such as totalling or summarizing. When using ABC (or other Clarion FILE processing) to retrieve data in a class, always be aware of the possibility that you will trash a record buffer that some other part of the program relies on. If you do trash it, document it so other programmers will know--and you will remmber--and can take steps. Because the class declaration is good mini-documentation for a class, you usually need no more than a small comment. (See the declaration of the TeamsClass2Type class.) To preserve record buffers, see the documentation on the FileManager.SaveFile and FileManager.RestoreFile methods in Clarion's help system. You can implement that in the class if you want, before and after the data retrieval. ===== By the way, I've changed the way the exported CSV file is viewed in the sample app. It now loads Excel with the CSV file if you have Excel on your system and it's set up with CSV as a file association. If you don't have Excel, see the code for the csvExporterClassType for how to do something else. Also note that I've moved the code for the GeneralClassType.GenericQueueViewer method to a class all by itself, and now I simply have GeneralClassType.GenericQueueViewer use that class. Classes allow you to make changes to enhance functionality like that, without breaking any code elsewhere in the program. Dan


Today is April 25, 2024, 4:06 am
This article has been viewed 35112 times.
Google search has resulted in 17 hits on this article since January 25, 2004.



Back to article list   Search Articles   Add Comment   Printer friendly

Login

User Name:

Password: