Re: Why you shouldn't be afraid to use VARCHAR in RPGLE

Javier Sanchez <[email protected]>
Newsgroups gmane.comp.lang.as400.rpg
Message-ID <CAAvhgxLAUon6A4sx=1SybJ44oosCzq9OEYXVdwkKM4gf0gYtWQ@mail.gmail.com>
Peter,

Sorry, I missed saying "You are right".  That is the spirit of it.

Thanks!
JS

El vie, 12 dic 2025 a las 1:22, Peter Dow (<[email protected]>) escribió:

>     dcl-s boolVar IND inz;
>
>     boolVar = (a = b ? '1': '0');
>
>     It's your choice.  That is RPG valid code above.
>
> I assume you mean that the DCL-S is valid RPG code, since the request
> was to have a construct like
>
> boolVar = (a = b ? '1': '0');
>
> in RPG.
>
> RPG does not have ==, just =, but in the context of
>
> boolVal = (a = b);
>
> the (a = b) is the same as the C (a == b), correct?
>
> In that case, unless RPG comes up with some operator that distinguishes
> between = (assignment) and == (test for logical equivalence), the
> closest we can get to the C version is
>
> boolVal = (a = b); // the equivalent of the C expression boolVal = (a ==
> b ? '1' : '0');
>
> If the C expression was
>
> resultString = (a == b ? 'Hello' : 'Goodbye');
>
> RPG would require
>
> if a = b;
>      resultString = 'Hello';
> else;
>      resultString = 'Goodbye';
> endif;
>
> and if the C expression was
>
> resultString = (a = b ? 'Hello' : 'Goodbye');
>
> RPG would require
>
> a = b;
> if b <> 0;
>      resultString = 'Hello';
> else;
>      resultString = 'Goodbye';
> endif;
>
> Meaning that the assignment of b to a is unconditional, but the
> assignment of 'Hello' or 'Goodbye' is conditioned upon the value of b
> being non-zero.
>
> --
> *Peter Dow* /
> 909 793-9050
> [email protected]
> /
> On 12/11/2025 6:56 PM, Javier Sanchez wrote:
> > Simple:
> > One line of code. The compiler would make the hard work with the return
> > value.  It is your intellectual work that you want back.  A string?  A
> > floating point? A char()? Whatever.  The single line is clear upon your
> > intention.
> > The == notation is "C", put that away in RPG.  Use only one = sign.
> > The return value is your intellectual work. Say it is an IND:
> > dcl-s boolVar IND inz;
> > boolVar = (a = b ? '1': '0');
> > It's your choice.  That is RPG valid code above.
> >
> > JS
> >
> >
> >
> --
> This is the RPG programming on IBM i (RPG400-L) mailing list
> To post a message email: [email protected]
> To subscribe, unsubscribe, or change list options,
> visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
> or email: [email protected]
> Before posting, please take a moment to review the archives
> at https://archive.midrange.com/rpg400-l.
>
> Please contact [email protected] for any subscription related
> questions.
>
>
-- 
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: [email protected]
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: [email protected]
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.

Please contact [email protected] for any subscription related questions.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.