|
From: "John Hall"
> Good point. IMHO I prefer the single statement If then construct. with
> begin end markers for multiple lines. This can make the code much more
> concise when you only need to execute one statement
>
> in RPGIV
>
> if a <= 0
> eval a=1
> endif
>
>
> in c
>
> if (a <= 0)
> a=1; // no endif is needed for a single statement
What's wrong with the following alternative:
a = iif( a<=0, 1, a)
For those of you that are not familiar with this, "IIF" is a logical
conversion function commonly found within other free format languages. It is
powerful, and very versatile. The syntax is as follows:
iif( condition, true_expression, false_expression)
Just a small example of how we can find better ways to do things if we take
the time to look at what has been done elsewhere.
> if (a <= 0)
> {
> a=1;
> b=1;
> } // Very clear as to where the block begings and ends
Until you start nesting the suckers.
Regards,
John Taylor
Canada
+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.