× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Henrik,

In RPG there is no concept of "null", or "no value" (same thing).
So any debate on how to interprete "empty string" and "null" is moot, within
the context of RPG.

What you are describing are RPG semantics, which where in place since the
beginning of time, when there where only fixed length fields.
Now we also have varying, C-like strings, etc.


The RPG semantics for comparing two "strings", or two fixed character
fields, or varying length fields, etc, are always and consistently
"converted" to comparing two fixed length fields. And the RPG semantics are
that the shortest field is padded with blanks up to the length of the
longest field. This is not a bug, but a feature. So '' is not an empty
string, but a string with zero, one, two etc blanks, if it's compared to
another character value. This is the same answer given already multiple
times on this thread.


On Tue, Oct 11, 2011 at 4:52 PM, Henrik Rützou <hr@xxxxxxxxxxxx> wrote:

To me it isn't logical,

if you reset a variable field to "no value" you do it with

string = '';

%len(string) will display 0

so why is a compare with '' not equal to the setting of the field while
it (whatever there may be in memory) works if you do

string = 'abc';
if string = 'abc'; // will pass

string = 'abcd';
if string = 'abc'; // will fail

?

I have of course just changed my code to %len(string) > 0;





On Tue, Oct 11, 2011 at 4:40 PM, <rob@xxxxxxxxx> wrote:

If I change it to:
string = x'0515' + 'abc';
string='';
and debug it on an active line after the above I get
00000515 81828300 - ....abc

but if I change it to:
/free
*inlr=*on;
string='';
then none of the DSPLY's kick in, and
EVAL string :x
00000000 00000000 00000000 00000000 - ................
so, apparently
00050515 81828300 00000000 00000000 - ....abc........
is less than
00000000 00000000 00000000 00000000 - ................

Rob Berendt
--
Group Dekko
Dept 1600
Mail to: 2505 Dekko Drive
Garrett, IN 46738
Ship to: Dock 108
6928N 400E
Kendallville, IN 46755
http://www.dekko.com





From: Henrik Rützou <hr@xxxxxxxxxxxx>
To: "RPG programming on the IBM i / System i" <rpg400-l@xxxxxxxxxxxx

Date: 10/11/2011 10:00 AM
Subject: RPG Error or ?
Sent by: rpg400-l-bounces@xxxxxxxxxxxx



Is it me that has misunderstood something or what would you expect
displayed from this code:

d string s 52a varying

string = x'0515' + 'abc';
or
string = x'4015' + 'abc';

// dosn't work (but works if x'4040' + 'abc')
if string > '';
dsply 'hello 1';
endif;

// works
if string <> '';
dsply 'hello 1';
endif;

// works
if %len(string) > 0;
dsply 'hello 2';
endif;


--
Regards,
Henrik Rützou

http://powerEXT.com <http://powerext.com/>
--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing
list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.


--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing
list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.




--
Regards,
Henrik Rützou

http://powerEXT.com <http://powerext.com/>
--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 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.