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



Hi Jon,

Cannot access my own code at the moment. Being unemployed and thus no access to a machine 8>(


But when converting a packed date field (length 8P0) with format YYYYMMDD to a format DD-MM-YYYYY it was something like this:

oldformat ('ABCDEFGH')

newformat('GH-EF-ABCD')

and then using xlate (or %xlate)

Newdate = %xlate(oldformat:%char(olddate):newformat) (with the corrected syntax from Chuck, I did not remember the exact syntax)

would change a date like

20160524 to 24-05-2016

ABCDEFGH GH-EF-ABCD

Newdate should have a length for the new string, thus length 10.

Worked for me. The article by Ted Holt learned me this nifty technique and I have used it since. Never looked at the newer BIFs to do the same thing. ("It ain't broke, thus ...")

Regards,

Carel Teijgeler



Op 24-5-2016 om 22:05 schreef Jon Paris:
Hi Carel,

I actually checked the manual to be sure I wasn’t mismembering before I responded to your post.

Just checked your code like so:

Dsply %xlate('1234':'12-3=4':'1234’);

And that results in 12-3 - which is exactly as it should be. Each character is replaced by the matching character from the mask. So the 1 is replaced by 1, same for 2, 3 is replaced by - because it is in the position that matches 3 in the from string. 4 is replaced by 3 because that is in the fourth position.

Can you check your production code because I have to believe it is not %Xlate that you are using.

Jon Paris

www.partner400.com
www.SystemiDeveloper.com

On May 24, 2016, at 1:53 PM, Carel <coteijgeler@xxxxxxxxx> wrote:

Sorry I have to disagree with you on this.

When

My input = 1234

My FromFormat = ABCD

My ToFormat = AB-C=D

then

output = %xlate(FromFormat:ToFormat:input) will be 12-3=4

Try it. I used this technique (learned from Ted Holt) to reformat dates.

Regards,

Carel Teijgeler



Op 24-5-2016 om 18:35 schreef Jon Paris:
Not really Carel - it only does a 1 for 1 replacement.

So turning this: “123456” into “123-456” would not be doable.

%ScanRpl is closer but still is in replacement mode whereas I really want to insert.

Looks like Steve’s subproc is the best starting point.


Jon Paris

www.partner400.com
www.SystemiDeveloper.com

On May 24, 2016, at 7:24 AM, Carel <coteijgeler@xxxxxxxxx> wrote:

I think XLATE/%xlate can be usefull here.


Regards,

Carel Teijgeler


Op 24-5-2016 om 0:26 schreef Jon Paris:
I know it is Monday but in theory it is a holiday here …

I need to edit some character fields - simply edits similar to what would be needed for a date.

My brain tells me there are functions to do this but edit words and codes only apply to numerics and even among the MI functions they are all numeric.

Am I mismembering? or do I really have to do it the hard way? Seems such a trivial requirement which is why I’m convinced I’m missing something.


Jon Paris

www.partner400.com
www.SystemiDeveloper.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.

Please contact support@xxxxxxxxxxxx for any subscription related questions.
--
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.


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.