A simple parallel routine

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
richdhan
Premium Member
Premium Member
Posts: 364
Joined: Thu Feb 12, 2004 12:24 am

A simple parallel routine

Post by richdhan »

Hi All,

I need to create a simple parallel routine which returns a substring. The C program to get the substring is as follows

Code: Select all

#include <stdio.h>
#include <string.h>
#include <malloc.h>
#include <math.h>

char *substr(char*,int,int);
main(int argc,char *argv[])
{
	char *z;
	z = substr(argv[1],atoi(argv[2]),atoi(argv[3]));
	printf("%s\n",z);
	free(z);
}
char *substr(char *str,int st,int len)
{
	int i,j=0,l;
	char *s;
	l = strlen(str);
	if(len > 0)
		s = (char *)malloc(100);
	else
		return("");
	if(l < abs(st))
		return("");
	if(st == 0)
		st = 1;
	if(st < 0)
		st = st + l + 1;
	for(i=st-1; i<st+len-1; i++)
	{
		s[j] = str[i];
		j++;			
	}
	s[j] = '\0';
	return(s);
}
I have the object file for this C program.

My concern is that the main program can return only integer. How to return string. How do I create a parallel routine that returns a string provided with the input string, the starting position and the length as inputs for the C object file.

Thanks in advance
--Rich

Pride comes before a fall
Humility comes before honour
Eric
Participant
Posts: 254
Joined: Mon Sep 29, 2003 4:35 am

Post by Eric »

A PX routine is a library/object file used by DataStage not an external program. These don't use 'main', you call the function directly.
Post Reply