Page 1 of 1

FIELD FUNCTION

Posted: Mon Dec 01, 2003 9:49 am
by MARKO970
HI ALL.

i' ve still a problem with special characters.
i cannot use some function with parallel xe and i'm looking for
the best performance way to retrieve special char from a srting.

someone knows if there is a function that retrieve more of one spec char
from a srting???? ex: ("MARK&O AND % SO*N")
CAN I EXTRACT ALL THE SPEC CHAR IN THIS STRING WITH A SINGLE FUNCTION????

can i use the field function???

thanks all for help!

Posted: Mon Dec 01, 2003 10:30 am
by 1stpoint
Do you want to extract or replace??
You may want to do an ereplace instead of a field..
Just an idea.

Posted: Mon Dec 01, 2003 10:39 am
by MARKO970
hi 1st,

i need to reject the rows if a field contain some special characters
so now i'm using COUNT or INDEX to know if the string contain a specific char(if return of these functions is 0, i know that the string is right...)
but so i have to process only one character at time ... if i have to control
10 character i have to do 10 controls ... there's a best function ???

p.s.
do you know how can i use IsValid function , there's an example someway ???

thanks for help...

Custom Function

Posted: Mon Dec 01, 2003 11:19 am
by 1stpoint
You can write your own custom function that would look something like this (the code below returns 1 if all characters are non-alpha chars:

Code: Select all

*IsValidString(Arg1)
Str=Upcase(ereplace(Arg1,' ',''))
Ans = 1
for i = 1 to len(Str)
    If (Str[i,1] < 'A' or Str[i,1] > 'Z') or
       (Str[i,1] < '0' or Str[i,1] > '9')  Then 
      Ans = 0 
      goto Done
    End
Next i
Done:

Posted: Mon Dec 01, 2003 11:30 am
by Teej
Unfortunately, this type of behavior have to be coded in. There is no equivalent standard function in C/C++ that does this task. The closest is strpbrk() which find the first appearance of any provided characters in a string.

If you wish to do it all within one function, you will definitely need to create a buildOP stage that does this task within a while loop for every row of data. Do a search on this forum for BuildOP or BuildOPS and you will get a number of guides that will help you get up to speed on this concept.

I do not see any equivalent transform function that does anything close to what you need to be done.

-T.J.

Posted: Tue Dec 02, 2003 5:18 am
by MARKO970
THANKS FOR HELP, NOW I TRY TO USE THE BUILOP (PRAY FOR ME ....)...

Posted: Tue Dec 02, 2003 10:25 am
by ray.wurlod
You could upgrade to version 7, and get the BASIC Transformer stage.
8)

Posted: Tue Dec 02, 2003 11:14 am
by Teej
ray.wurlod wrote:You could upgrade to version 7, and get the BASIC Transformer stage.
8)
Sssh! The One must journey on the tough path for a while. 8)

-T.J.