[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index]
[Date Index]
[Thread Index]
[SQR-USERS Info]
[SQRUG Home Page]
Re: [sqr-users] Dynamic Substitution Vars
Matt,
I don't know if this will work for you, but in situations where
I've needed dynamic SQR code, I have writen an SQR program that
generates the SQR program (using WRITE or PRINT). You can even
use the generator program to launch the generated program using
CALL SYSTEM.
Ray
On Fri, Oct 17, 2003 at 04:26:20PM -0400, Matt Rogish wrote:
> All,
>
> I sent a message earlier about dynamic 'input' variables and got some
> interesting suggestions on and off list, none of which worked out quite as
> I had hoped.
>
> To re-cap:
> We have lots of programs which have this basic structure:
> set up variables
> ask for input
> run some SQL
> show report
> show summary
>
> In order to ease maintenance what I'd like to do is standardize the "set up
> variables", "ask for input", and "show summary" pieces using some sort of
> dynamic SQR.
>
> In the summary section we list some report variables (counters and things)
> and we like to list the input parameters because there's nothing like
> getting a complex multi-section report and trying to guess what input
> parameters the particular report was run with (because the user forgets, or
> you look at the report a month later, or they were in Brio Portal but have
> since been changed, etc.).
>
> The way we have it now is something like this:
> begin-procedure get-input
> Input $code 'Enter some code'
> Input $begin_date 'Enter report begin date' type=date
> ..
> end-procedure
>
> begin-procedure show-input-summary
> print 'Input Parameters:' (+1) bold
>
> print 'Some Code: ' (+2)
> print $code
>
> print 'Begin Date: ' (+2)
> print $begin_date
>
> etc.
> end-procedure
>
> Oftentimes there are many parameters so it becomes cumbersome to list long
> blocks of Input and print statements. It also makes maintenance a
> nightmare because you don't know which programs require what input and if
> you want to change/add one you have to change it several places.
>
> So, the goal is to minimize code changes when the input parameter list
> changes -- either by adding, changing, or removing input
> parameters. Preferably, there would be one spot in the program where I
> change a parameter list and the get-input and show-input-summary procedures
> do not have to change! It goes without saying that there might have to be
> other changes to handle the addition or removal of a parameter, but that
> can come later. :)
>
> Some ideas I've considered are:
> Idea One -- Build an array which stores the input parameter name
> ("some_code") and input query string ("Enter some code") then loop through
> each one and build an 'Input' statement from this.
> Problem:
> I don't know how to execute dynamic SQR code, namely something like:
> let $stmt = 'Input $' || $input_var_name || ' ''' || $input_query || ''''
> [$stmt]
> This gives an error:
> (SQR 4008) Unknown function or variable in expression: [$stmt]
>
> Idea Two -- Create substitution variables, loop through each of them, and
> use them in Input statements.
> Problem:
> I can't dynamically *name* a substitution variable:
> Let #num = 1
> #DEFINE variable_number_#1
> Show {variable_number_1}
> This gives an error:
> (SQR 4707) No value found for substitution variable: {variable_number_1}
>
> Any help/ideas?
>
>
> Thanks,
>
> --
> Matt Rogish - rogishmn@muohio.edu
>
> _______________________________________________
> sqr-users mailing list
> sqr-users@sqrug.org
> http://www.sqrug.org/mailman/listinfo/sqr-users
----------------------------------------------------------------------
Ray Ontko rayo@ontko.com Phone 1.765.935.4283 Fax 1.765.962.9788
Ray Ontko & Co. Software Consulting Services http://www.ontko.com/
_______________________________________________
sqr-users mailing list
sqr-users@sqrug.org
http://www.sqrug.org/mailman/listinfo/sqr-users