Powerbuilder ‘Gotcha’ – Datawindow.Create function

Posted on Tuesday, July 13th, 2010 at 8:20 pm in

I’m working in a custom report application and a tester who is auditing the changes is getting an syntax error when she tries to run her report. The report generator takes the list of columns chosen by the user and builds a SQL statement which is then fed through the SyntaxFromSQL function to generate the string from which the report datawindow is generated via the Create function. The error is being generated by the Create and takes the form of ‘Syntax error, line 25, column 174).

However, the source code generated from the SyntaxFromSQL is being appended to to create groups and other nice things and this is where the actual problem arose. Example code is:

ls_group_syntax += " text(band=foreground alignment='0' text='" + ls_rpt_title + "' border='0'...
ls_group_syntax += " text(band=foreground alignment='0' text='" + string(today(), 'mm/dd/yyyy') +...
ls_group_syntax += " compute(band=footer alignment='1' expression=~'"Page " + page() + " of "...

Notice the variable ls_rpt_title. As it turns out the user was naming the report Ann’s Report which messed up the string making up the group syntax. One change would be to switch single and double quotes in the building of the string. Another change is to put in your documentation for the users to not use quotes in report titles.

You might also be interested in

1 Comment

Add your comment

  1. jwayt@iobar.com - October 21, 2012 at 7:09 am

    Yet another option would be to replace the quote (‘) with tilde-quote (~’), as is done in line 3 of the example.

Leave a Reply

Top