× 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.



0001.00 d pos1 s 1 0 dim(20)

1 byte - the zero would have been 10...

Jim

-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Wells,
Joe J
Sent: Friday, June 09, 2017 4:21 PM
To: 'rpg400-l@xxxxxxxxxxxx'
Subject: RE: Unexpected SCAN Opcode Result

Thank you for the replies.

I learned something today.

For the record, I have been programming in RPG for over 25 years.......never
hit this problem before.

Thanks again.

From: Wells, Joe J
Sent: Friday, June 09, 2017 10:53 AM
To: 'rpg400-l@xxxxxxxxxxxx'
Subject: Unexpected SCAN Opcode Result

Before posting this, I did some quick research and did not find anything
about this issue........forgive me if it is well known and I simply
overlooked it!

Had an interesting problem this morning and I was surprised that it did not
throw an error........

Wrote a short test program to illustrate the issue -

0001.00 d pos1 s 1 0 dim(20)
0002.00 d pos2 s 2 0 dim(20)
0003.00 d string s 20a
0004.00
0005.00 c eval string=
0006.00 c '1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|'
0007.00
0008.00 c '|' scan string pos1
0009.00
0010.00 c '|' scan string pos2

Here's what pos1 shows -

POS1(1) = 2.
POS1(2) = 4.
POS1(3) = 6.
POS1(4) = 8.
POS1(5) = 0.
POS1(6) = 2.
POS1(7) = 4.
POS1(8) = 6.
POS1(9) = 8.

And here's what pos2 shows -

POS2(1) = 02.
POS2(2) = 04.
POS2(3) = 06.
POS2(4) = 08.
POS2(5) = 10.
POS2(6) = 12.
POS2(7) = 14.
POS2(8) = 16.
POS2(9) = 18.


See the problem? POS1 is wrong because it only is only 1 position. The
values are getting truncated and SCAN is not throwing an error.

POS2 is correct. It has 2 positions.

Has anyone seen this before?

Thanks,

Joe



--
This is the RPG programming on the IBM i (AS/400 and iSeries) (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.

Please contact support@xxxxxxxxxxxx for any subscription related questions.

Help support midrange.com by shopping at amazon.com with our affiliate link:
http://amzn.to/2dEadiD


As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.