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



I think the most elegant solution would be to use a simple substring. I
use the a string based on the indicator array frequently, and if I want
to set a certain section of the array I use a substring:

d pIndicators s * inz(%addr(*in))
d indicators s 99a based(pIndicators)

/free
%subst(indicators:30:3) = '101';
return;
/end-free

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Booth Martin
Sent: 22 January 2013 19:51
To: RPG programming on the IBM i (AS/400 and iSeries)
Subject: Re: truncating a decimal value in /Free (Hijacked &
Solved...thehijacked that is)

Buzz,
This worked:
http://www.martinvt.com/Code_Samples/Setting_Indicators/setting_indicato
rs.html

DINDICATORS ds
D exit 1n overlay(INDICATORS: 3)
D cancel 1n overlay(INDICATORS: 12)
DNamedInd ds 99
D Errors 3 overlay(NamedInd: 30)
D IN30 1 overlay(NamedInd: 30)
D IN31 1 overlay(NamedInd: 31)
D IN32 1 overlay(NamedInd: 32)
...
Errors = '010';
INDICATORS = NamedInd;

It is more than one line, but it works plus it gives you named
indicators.





On 1/22/2013 9:43 AM, Buzz Fenner wrote:
To summarize (and to provide some background) I was faced with the
following coding style during a modification to some RPG III code:

C MOVEA'101' *IN,30

This has been used extensively in my shop for the last 30 years. I'm
trying to show the other guys the advantages of /Free but I wasn't
able to do the same thing with just a single line of code. Posting the

problem to the forum helped me a lot, and it also garnered the usual
comments about bad coding techniques. I'll give you that, but I'm in a

bit of an ideological war here and unless I can reproduce the same
results using a single line of code, I'll lose this battle. So much
for background...

Got pointed to a Jon Paris article (thanks!) and came up with the
following:

D pIndicators s * inz(%addr(*in))

D indicators ds based(pIndicators)
D ind 1a overlay(indicators)
dim(99)

In his original, the array elements were defined as 1n, but I changed
it to what you see. The calc statement became this (since there's no
equivalent to MOVEA in free form):

C %subarr(ind:30:3) = '101';

The compiler balked when the array was defined as 1n, but accepted 1a.

I ran some test data and things looked OK, and I thought my problem
was solved, until I tested more thoroughly.

In short folks, it didn't work. Debugging the statement shows the
following:

General Indicators:

... 30 '1' 31 '1' 32 '1' ...

Before the %subarr statement, they were all '0'.

So, I'm back to the drawing board but needed to inform the list so
someone else doesn't try the same thing!

Buzz





--
Booth Martin
802-461-5349
http://www.martinvt.com
--
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.


-----------------------------------------------------------------------
The information contained in this email is confidential and may also contain privileged information. Sender does not waive confidentiality or legal privilege. If you are not the intended recipient please notify the sender immediately; you should not retain this message or disclose its content to anyone.
Internet communications are not secure or error free and the sender does not accept any liability for the content of the email. Although emails are routinely screened for viruses, the sender does not accept responsibility for any damage caused. Replies to this email may be monitored.
For more information about the Tullett Prebon group of companies please visit the following web site: www.tullettprebon.com

-----------------------------------------------------------------------

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.