[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index] [Date Index] [Thread Index]
[SQR-USERS Info] [SQRUG Home Page]

Re: Conditional printing



Raj,

There are two work-arounds to this problem that I have tried, depending on what 
is applicable and what appeals to you:

(a)     if your condition can be expressed by a substitution variable, you 
could do something like:

                print $xyz () {bold}

        or
                print $xyz () {format}

        where {bold} or {format} could be determined via #define or ask, and 
would consist of something like "bold" or "bold underline" or "edit 999 bold"

(b)     you could write a wrapper function for print, like so:

        BEGIN-PROCEDURE print-formatted ($text (or #num), #bold, #underline, 
<other formatting parameters, line and/or column, etc.>)
        ...
                if #bold
                        if #underline
                                print $text bold underline
                        else
                                print $text bold
                        end-if
                else
                        if #underline
                                print $text underline
                        else
                                print $text
                        end-if
                end-if
        END-PROCEDURE

This obviously gets more or less complicated depending on how many parameters 
you throw in, but at least you only have to write it once.

Hope this helps,
- Mark

                -----Original Message-----
                From:   Jamadagni, Rajendra [mailto:rajendra.jamadagni@ESPN.COM]
                Sent:   Tuesday, April 11, 2000 10:28 AM
                Subject:        Conditional printing

                Hi all,

                is it possible to control the printing conditionally?
                I need to print a line in normal font if a variable is FALSE, 
and in BOLD
                when the variable is TRUE. Can this be achieved in one print 
statement? I
                wouldn't mind two, but I am printing about 26 columns on each 
line and don't
                want 52 print commands.

                I tried to put BOLD as a char value in a variable and used that 
in print
                print &col2 (0, 26) $print_attrib

                but it resulted in an error ....

                Thanks for your help
                Raj