Page 1 of 2

Routine Function

Posted: Mon Feb 06, 2012 10:47 pm
by oracle
Hi All ,

I have the below requirement .Please help me to write routinee function ?

Input: string (varchar) -> any character string
Output: int -> the position of first non-numeric character of the input string. If all are numbers return -1.

E.g.
Input Output
ADB234 1
123ABC 4
12 456 3
1224-52 5
1234 -1


Regards
Ora

Re: Routinee Function

Posted: Tue Feb 07, 2012 3:14 am
by oracle
Hi All

I have developed server routinee for this logic .But I ca n't call server routinee in transformer stage.

Code: Select all

ConvertString=CONVERT(' ABCDEFGHIJKLMNOPQRSTUVWXYZ-!@#$%^&*()_+=<>?|`/\:.,;"','####################################################',Arg1)

StringPosition=INDEX(ConvertString,'#',1)

if num(Arg1)=1  then
Ans=-1
end
Else 
Ans=StringPosition
end

Can you please help me to write parallel routinee using above server routinee?

Posted: Tue Feb 07, 2012 3:18 am
by kandyshandy
Why parallel routine?

Posted: Tue Feb 07, 2012 3:33 am
by oracle
Hi ,

Thanks for your quick reply.
We can't call server routineee in transformer stage .Due to that reason I want parallel routinee.Please guide me?

Posted: Tue Feb 07, 2012 3:37 am
by kandyshandy
Why routine at the first place? Did you try in a transfomer?

Posted: Tue Feb 07, 2012 3:59 am
by oracle
Hi,

I tried in transformer stage with out using routinee and its working fine.But for reusable purpose they are expecting one routinee which will take input and retuen postion of the string.

Regards

Posted: Tue Feb 07, 2012 5:32 am
by ray.wurlod
It appears to me that you lack C++ programming skills and want someone else to create the routine. You have implemented the logic in a Transformer stage, so that part is under control. Why not inspect the C++ source code that is generated when the Transformer stage is "compiled"? You will find this in the RT_SCnnn sub-directory in the project, where nnn is the job number from DS_JOBS table.

Posted: Tue Feb 07, 2012 6:05 am
by oracle
Hi Ray,

Thank you very much for your reply.

I don't have C++ programming skills and I want to develop parallel routinee .Can you please provide me the simillar template if you have .

thanks

Posted: Tue Feb 07, 2012 7:50 am
by ray.wurlod
Search DSXchange for examples, for example pxEreplace().

Posted: Tue Feb 07, 2012 10:55 am
by rupeshg
Have you tried creating a Transform ? That is reusable too.

Posted: Tue Feb 07, 2012 6:27 pm
by ray.wurlod
rupeshg wrote:Have you tried creating a Transform ? That is reusable too.
Transforms are only applicable in server jobs and BASIC Transformer stage.

Posted: Wed Feb 08, 2012 2:42 am
by oracle
Hi Ray,

Can you please provide me the simillar kind of parallel routinee if you have that .

Thank you very much

Posted: Wed Feb 08, 2012 2:54 am
by ray.wurlod
I don't have one. That's why I told you to search DSXchange.

Posted: Wed Feb 08, 2012 5:07 am
by oracle
Hi All

I have developed parallel routine to get the position of first non-numeric character of the input string.Unfortunatley I don't have compiler previllages and can any one please execute the progarm and tell me the result if possible ?

Regards


Code: Select all

/****************************************************************************** 
* FirstNonNumPos
* 
* Finds the first character in a list of characters 
* e.g. [b]FirstNonNumPos( "1234abcd" ) returns 5[/b]* 
******************************************************************************/ 

#include <cstdlib>
#include <iostream>

using namespace std;

int findchar(char *str)
{
    int i=0;
    while(1)
    {
            if((str[i]>=48)&&(str[i]<=57))
            {
             ++i;
            continue;
            }
            else
            break;
           
    }
    return (i+1);
}            

Posted: Wed Feb 08, 2012 6:17 am
by oracle
Hi All,

Can you please let me know where do i have to place the parallel routine (C++ program) and also I need a command to run the C++ program in unix


Regards