[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index]
[Date Index]
[Thread Index]
[SQR-USERS Info]
[SQRUG Home Page]
Re: Setting Variable Procedure Names
Paul,
Here is a solution that you might find acceptable.
The basic approach is to add a "dispatch" procedure.
Instead of:
Do $procedure
you would say:
Do dispatch( $procedure )
where "dispatch", looks like this:
begin-procedure dispatch( $procedure )
lowercase $procedure
evaluate $procedure
when = 'show_fred'
do show_fred
break
when = 'show_wilma'
do show_wilma
break
when = 'show_barney'
do show_barney
break
when = 'show_betty'
do show_betty
break
when-other
show 'unknown procedure: show_' $procedure
move 1 to #_return-status
stop quiet
end-evaluate
end-procedure ! dispatch
This isn't much worse than what you were hoping for. Since
you have to add the new show_XXX procedure anyway, you just need
to add a few lines to the dispatch procedure for each new show.
Also, note that if you needed to pass parameters to the procedures,
and they all take the same parameters, you can easily add them to
the dispatch procedure and pass them along to the individual called
procedures.
Hope this helps.
Ray
> Hi there all,
> I'm new to this list and decided to post a question. Does anyone know
> if it is possible to assign a Value to a variable and then call that
> veriable as a procedure:
> for example, in my error-handling I want to display all of the variables
> that I was trying to insert or update when I caused and error. I have
> created a "Show" procedure for each of my Insert procedures but I don't
> want to hard-code the search for which procedure erred out. (Laziness).
> Also each procedure is seperate and unique so it is not as if I can pass
> parameters
> "Do show_procedure($whatever)". Below is what I want to do, sort of, but
> it doesn't work. Has anyone tried anything similar and succeeded?
>
> If #sql-status = -9
> !Duplicates on insert
> Else
> Show 'Error in Procedure : ' $proc
> Show 'SQL-Error = ' $Sql-Error
> Show 'SQL-Status = ' #SQL-Status
> Let $procedure = 'Show_' || $proc
> Do $procedure
> End-if
>
> Thanks and regards,
> Paul
>
>
> -------------------------------
> The information transmitted is intended only for the person or entity to
> which it is addressed and may contain confidential and/or privileged
> material. Any review, retransmission, dissemination or other use of, or
> taking of any action in reliance upon, this information by persons or
> entities other than the intended recipient is prohibited. If you received
> this in error, please contact the sender and delete the material from any
> computer.
>
----------------------------------------------------------------------
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/