ClarionLive show notes for June 14 2013

Arnold wanted to know how to handle company logos, as when a customer provides an image file to the software and that image gets printed on reports. 

Mike indicated 300 DPI is pretty standard for printing purposes. JPG works fine, but Clarion still has issues with PNG sometimes. BMP are fine (bug big). WMF files don't transition to PDF properly but can be used straight to printer. So JPG and BMP are the safest. 

Start with a blank image control. In Mike's example he set the height to a fixed value but omitted the width parameter in the AT statement so the control will adjust to the image's aspect ratio. 

He then adjusted the pop:XPos of any controls to the right of the image in the report header, after the image has been assigned to the control. 

If you do need to resize an image there is a function in CWUtil called ResizeImage (also mentioned in the help).

Main presentation - Invoice.dct

Recently a number of the CIDC 2013 presenters got together to discuss some of the themes emerging from the conference sessions, including code refactoring. It was decided that for at least several of those discussions a common APP would be a useful tool. 

That app is Invoice.app, which has been part of the shipping examples since, well, a rather long time ago. Because of its age Invoice.app is useful (at least as far as the conference presenters are concerned) as an example of how Clarion code ought not to be written. That makes it fertile ground for refactoring. 

Some of that refactoring is happening before the conference. In today's webinar Mike Hanson started in on Invoice.dct. As shipped, this dictionary has tables with inconsistent names, key settings that bode ill for SQL, only partial use of primary autoinc keys, and other issues. 

Some of the changes Mike went through include renaming the files, using the convention of singular rather than plural names wherever possible, and making sure all names are descriptive.

Old table nameNew table name
CompanyCompany
CustomersCustomer
DetailInvoiceDetail
InvHistInventoryLog
OrdersInvoice
ProductsProduct
StatesStates*

*States was left as States after much debate, as State is a reserved word in SQL and the proposed alternatives were unappealing.

Mike ensured that all tables had a primary autoinc key; in a few cases he was able to use existing keys with suitable modification. 

Bruce Johnson brought up the problem of keys with excluded nulls. This is something that works for flat file systems like TPS and Btrieve, but not for SQL since there's no equivalent concept. It can be particularly nasty if you're using Require Unique Value along with excluded nulls, since that's a hybrid concept of uniqueness - unique only if the values exist. You really should try to avoid  these kinds of keys. 

With lots of discussion about various points it took until the end of the session to complete the dictionary changes. For fun, Mike tried generating and compiling. He got two generation errors (selections that were no longer available to templates) and less than 200 compile errors, a surprisingly small number given the significant dictionary changes. 

View the webinar at ClarionLive.com