Sie sind auf Seite 1von 4

// Define Validation string constants for RowId in Star Array Param

#define ROWID_VALSTR0 "-"


#define ROWID_VALSTR1 "1-"
#define ROWID_VALSTR2 "2-"
#define ROWID_VALSTR3 "3-"
#define ROWID_VALSTR4 "4-"
#define ROWID_VALSTR5 "5-"

//Define Copy Options


#define COPY_ALL 1
#define COPY_ROWID 0

//Function Declarations
void Copy_StarArray(char *source_prm,const char *targt_prm, int copy_opt);
int Pick_ValidStarArray(const char *frst_StarArrPrm,int No_StarArrys,char *Vald_
rowIdStr, int copy_opt);

//Function Definitions
void Copy_StarArray(char *source_prm,const char *targt_prm, int copy_opt)
{
unsigned long prmLen,in_Len;

int Loop_count,status;

char src_prmStr[35];
char trgt_prmStr[35];
char tmp_prmStr[35];
char *out_Buff=0;

//Update the strings to represent rowid element of the star arra


ys
sprintf(src_prmStr,"{%s_rowid}",source_prm);
sprintf(trgt_prmStr,"%s_rowid",targt_prm);
//Copy the rowid into Target star array param
lr_save_var(lr_eval_string(src_prmStr),strlen(lr_eval_string(s
rc_prmStr)),0,trgt_prmStr);

//Check the copy option


//Return if 0 and continue if 1
if(copy_opt==0)
return;
// Save the Source and Desination star array param names into a
string to evaluate each
//each element of the array
sprintf(src_prmStr,"{%s_1}",source_prm);
sprintf(tmp_prmStr,"{%s_1}",source_prm);

sprintf(trgt_prmStr,"%s_1",targt_prm);

out_Buff=(char *)lr_eval_string(src_prmStr);

status=stricmp(out_Buff,tmp_prmStr);

for(Loop_count=1;status!=0;Loop_count++)
{
//Save the source star array param element into target star ar
ray param
lr_save_var(out_Buff,strlen(out_Buff),0,trgt_prmStr);
if(Loop_count!=1)
lr_eval_string_ext_free(&out_Buff);

//Update the strings to represent next element of the star arr


ays
sprintf(src_prmStr,"{%s_%d}",source_prm,Loop_count+1);
sprintf(tmp_prmStr,"{%s_%d}",source_prm,Loop_count+1);
sprintf(trgt_prmStr,"%s_%d",targt_prm,Loop_count+1);

in_Len=(unsigned long )strlen(src_prmStr);


//Evalauate the next source star array element into output buff
er
//and check if that is a valid LR param. An invalid param means
all values copied
lr_eval_string_ext(src_prmStr,in_Len,&out_Buff,&prmLen,0,0,-1
);
status=stricmp(out_Buff,tmp_prmStr);

}//end of FOR Loop


lr_eval_string_ext_free(&out_Buff);

}//End of Copy function

int Pick_ValidStarArray(const char *frst_StarArrPrm, int No_StarArrys, char *Val


d_rowIdStr, int copy_opt)
{
int StarArr_Ord,Loop_count;
char *rowid_pos=0;
char nxt_StarArrPrm[50];

sprintf(nxt_StarArrPrm,"{%s_rowid}",frst_StarArrPrm);
rowid_pos=(char *)strstr(lr_eval_string(nxt_StarArrPrm),Vald_row
IdStr);

for(Loop_count=1;rowid_pos==0&&Loop_count<No_StarArrys;Loop_coun
t++)
{
sprintf(nxt_StarArrPrm,"{%s+%d_rowid}",frst_StarArrPrm,Loop_count);
rowid_pos=(char *)strstr(lr_eval_string(nxt_StarArrPrm),
Vald_rowIdStr);

}// End of For Loop


if(Loop_count==No_StarArrys&&rowid_pos==0)
StarArr_Ord=-1;
else
StarArr_Ord=Loop_count-1;

switch(StarArr_Ord)
{
case -1: lr_message("Star Array: %s not found at any of
the anticipated ordinals",frst_StarArrPrm);
return -1;
break;
case 0: break; //No need to copy, Star array found at d
esired ordinal
default: sprintf(nxt_StarArrPrm,"%s+%d",frst_StarArrPrm,
StarArr_Ord);
Copy_StarArray(nxt_StarArrPrm,frst_Star
ArrPrm,copy_opt);// Function Call to copy star array
break;
}
return 0;
}// End of Pick_ValidStarArray function

Das könnte Ihnen auch gefallen