×

Good News Everybody!

The new search engine is LIVE!

Please report any problems to david (at) midrange.com.




As John has said "situation normal" for old style RPG which is what you have used.

If you had been using the free-form approach (which goes all the way back to V5R1) and used %Scan you would have seen a very different result,


Jon Paris

www.partner400.com
www.SystemiDeveloper.com

On Jun 9, 2017, at 11:52 AM, Wells, Joe J <jwells@xxxxxxxxx> wrote:

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