View previous topic :: View next topic
|
Author |
Message |
bnrinbox
New User
Joined: 15 Feb 2005 Posts: 4
|
|
|
|
As per my requirement i have to check any spl char used as data or not in a string. Is there any built-in function available? Please let me know. If no builtin function available, let me know, how to find through code?
Thanks alot |
|
Back to top |
|
|
ravi1
New User
Joined: 27 Apr 2006 Posts: 11
|
|
|
|
bnrinbox wrote: |
As per my requirement i have to check any spl char used as data or not in a string. Is there any built-in function available? Please let me know. If no builtin function available, let me know, how to find through code?
Thanks alot |
I think You can find the special character in a string using INDEX function.
DCL DATA1 BIN(31,0) INIT(0);
DCL STRING1 CHAR(10);
STRING1 = 'ADCF@EFGHI';
DATA1 = INDEX(STRING1,'@');
IF DATA1 = 0
THEN PUT SKIP LIST('SPECIAL CHARACTER NOT FOUND');
PUT SKIP LIST('DATA1:', DATA1);
HERE DATA1 WILL RETURN '5' SINCE @ IS PRESENT IN THE 5TH POSITION OF THE STRING. |
|
Back to top |
|
|
k_vikram07
New User
Joined: 23 Nov 2005 Posts: 35
|
|
|
|
YOu can use VERIFY to check the existance of SPL characters.
DCL specialchar char(12) INIT('!@#$%^&*()_+}{|"><');
DCL input CHAR(15);
IF VERIFY(input,specialchar) = 0
THEN /* there is no special character in input variable*/;
ELSE
/* special character used */;
You can include any character, you think is special, in the init of the specialchar variable. See usage of VERIFY for more info.
-Vik. |
|
Back to top |
|
|
k_vikram07
New User
Joined: 23 Nov 2005 Posts: 35
|
|
|
|
Sorry, the function is SEARCH not VERIFY.
-Vik |
|
Back to top |
|
|
|