× 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 would scan for the text LINE using the %SCAN built in function and then
take the four characters beginning 5 positions after the text "LINE". Once
I had that I would check each character to see if it was numeric and if not
I would replace it with a blank and then prefix the trimmed result with
"0000" and take the last four characters.

This assumes, of course that you wouldn't have any non-digits between two
digits in your text, e.g. "5.2 ".

An example program and subroutine that does this is below, I hope it helps.

All the best

Jonathan




D String s 64a Dim(3) PerRcd(1) CtData
D wLine s 4a

D GetLineNo Pr 4a
D iString 64a Const

C Eval wLine = GetLineNo(String(1))
C wLine Dsply

C Eval wLine = GetLineNo(String(2))
C wLine Dsply

C Eval wLine = GetLineNo(String(3))
C wLine Dsply

C Eval *InLR = *On
C Return

C* --------------------------------------------------------

P GetLineNo b

D GetLineNo Pi 4a
D iString 64a Const

D oLine s 4a
D wPos s 2s 0

C Eval oLine = *Blanks

C Eval wPos = %Scan('LINE' : iString)
C If wPos > 0
C Eval oLine = %Subst(iString : wPos + 5 : 4)
C For wPos = 1 to 4
C If %Subst(oLine : wPos : 1) < '0' or
C %Subst(oLine : wPos : 1) > '9'
C Eval %Subst(oLine : wPos : 1) = *Blank
C EndIf
C EndFor
C EndIf

C EvalR oLine = '0000' + %Trim(oLine)
C Return oLine

P GetLineNo e

** CtData
SALES ORDER 644535 AND LINE 5. XXXXXXX
SALES ORDER 12345 AND LINE 123. XXXXXXX
SALES ORDER 11223344 AND LINE 8765. XXXXXXX




-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]
On Behalf Of Steve Jones
Sent: 05 September 2008 16:23
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

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.