Hi Steve,

Here's a procedure, although it relies on constant values within the
text. I haven't tested it, and it's definitely tweakable based on your
more intimate knowledge of the situation. I wasn't sure if the end
result should be numeric. If not, and you want leading zeros, wrap the
%dec in a %editc with a code of 'X'.


//======================================================================
*
// Get the Line Number
*
//
*
// Parameters:
*
// Input - String of text with the line number.
*
// Output - Line Number
*
//
*
// Return Value: Error indicator. '1' - denotes an error
*
//
*

//----------------------------------------------------------------------
*
P getLineNumber B
D PI n
D input 50a Const
D lineNumber 5p 0

// Local Constants
D SCAN_VALUE1 C 'LINE '
D SCAN_VALUE2 C '.'

// Local Variables
D pos1 S 3u 0
D pos2 S 3u 0
D rtnError S n Inz( *On )

//----------------------------------------------------------------------
*
/Free

pos1 = %scan( input: SCAN_VALUE1 );

If pos1 > 0;
pos1 += %len( SCAN_VALUE1 );

pos2 = %scan( input: SCAN_VALUE2: pos1 );

If pos2 > 0;

Monitor;
LineNumber = %dec( %subst( input: pos1: (pos2 - 1) ): 5: 0
);
rtnError = *off;
On-Error;
EndMon;

EndIf;
EndIf;

Return;

/End-Free
P getLineNumber E

//----------------------------------------------------------------------
*


Kurt Anderson
Application Developer
Highsmith

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Steve Jones
Sent: Friday, September 05, 2008 10:23 AM
To: rpg400-l@xxxxxxxxxxxx
Subject: Scanning Text

I know this can be done alot easier than we are currently, so I thought
I would ask for your suggestions. I have a field that contains "SALES
ORDER 644535 AND LINE 5. XXXXXXX" We need to pull out the next 4
characters after LINE & put that into a character field length of 4 to
be processed later. Now we only want numbers, no characters to be in
the end result. In this example we would like to have "0005" placed
into our field. Now if the file contained "SALES ORDER 644535 AND LINE
155. xxxxxxxxx" we would need it to have "0155" The field is fixed in
length BUT the starting position of LINE could be different.

Any suggestions on how to do this?

Thanks in advance
Steve
--
This is the RPG programming on the AS400 / 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.


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.