Page 1 of 1

Looping Using Stage Variable

Posted: Thu Oct 22, 2009 12:01 am
by sjordery
I have a requirement like this:

The input file has one column called code whose value is 7878D0990.
In that I need to search from backward and get the alphabet found i.e D.
The value changes in every run.

I am thinking to use stage variables but not sure how to perform looping using stage variables.
Any help will be appreciated.

Thanks in advance.

Posted: Thu Oct 22, 2009 12:13 am
by ray.wurlod
Given that you've marked this as a server job:

Code: Select all

MatchField(InLink.Code, "0N1A0N", 2)

Posted: Thu Oct 22, 2009 12:44 am
by sjordery
Thanks Ray.
This is working if one string is there before the numbers from back word.
for e.g if the string is 5656D09 then MatchField("5656D09", "0N1A0N", 2)is returning the correct vale D.

But ,if the string is 5656ID09 then MatchField("5656ID09", "0N1A0N", 2)is returning null where result should be D?
Any sugesstions?

Thanks,
SJ.

Posted: Thu Oct 22, 2009 6:35 am
by chulett
I don't see how 'matches' can get you the last occurance, at least not easily. Perhaps Ray knows some magic for that. :?

Me, I would build a routine that does the 'looping' you asked about. Check the length of the string, execute a For loop stepping from that to 1 step -1, use substring at that position to check for Alpha() and exit the first time time returns true.

Posted: Thu Oct 22, 2009 3:56 pm
by ray.wurlod

Code: Select all

Right(MatchField(InLink.Code, "0N0A0N", 2), 1)