PowerBuilder – Number of Characters Remaining in a String Column

Posted on Thursday, October 21st, 2010 at 8:20 pm in

A system I developed a while back was essentially a front end for a COBOL zSeries application (System 390 for you old timers). As such I had to make sure my data played nice with the VSAM files and the functionality my app was essentaily replacing. In one instance the users had the ability to attach notes to a document. These notes took the form of 16 separate lines each limited to 45 characters each. As with many apps, over the years the users developed ‘business rules’ relating to these lines which were in no way enforced by the applications. By this I mean rules like ‘line three means something for a particular type of document and is left blank for all others unless the part is of class Y in which it means something else.’

Since it would be impossible to collect and codify the informal rules in the time allotted for the project, I opted for a simple approach – emulate what they have currently. In order to let the users ‘keep’ their informal rules on these entries I created an external datawindow with 16 note columns of 45 characters each. To make things even more interesting, the ‘mainframe’ application used a fixed font size which made seeing the amount of characters left for a given note easy (Green Screen of 80 characters width)
and I always had to send all the notes (16 lines of 45 characters each) to it for processing.

Rather than waste screen space with a fixed font size I kept the system standard one but added a computed column for each of the sixteen note lines which showed the amount of characters remaining as the user typed. The expression on the computed column for the ‘note1’ column is:

if (isnull(note1),45,45 - len(note1))

Since the data typed in is not accepted from the buffer until after the itemchanged event, the computed column updates when the field loses focus.

You might also be interested in

Top