Convert Word to Number (ABCD to 0123)

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
icecreamsz
Premium Member
Premium Member
Posts: 1
Joined: Fri Nov 30, 2007 7:30 pm

Convert Word to Number (ABCD to 0123)

Post by icecreamsz »

Can someone help me, providing Parallel routine for the below format.Any help is highly appreciated thanks!


If any word is given as input , the ouput should be in its corresponding numbers.

Where

(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z)

need to be printed out as

(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25) respectively


For examples
1)

Input =ABCD

Output must be

Output =0123

2)

Input =CAB

Output=201

3)Input = ZEBRA

Output= 2541170

I can also provide server basic routine for this.If anyone can translate that too C++ .I could'nt able to convert.

Thanks a lot in advance
ray.wurlod
Participant
Posts: 54595
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

There's no consistent way to decode this. So why is it wanted?
For example 2541170 could decode as ZEBBHA.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

A 'for' loop for the length subtracting 'A' from each char is what you need.

Alternatively have 26 replace commands.

You can further simplify this as

outputString = replace('ab...j','0....9',inputField)

and do the rest 16.
Post Reply