Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

HELP IN SMALL QUERY

Former Member
0 Likes
459

Hi all,

I have a variable type c and want to know whether it contains only numericals are not.

Lets say

test(5) type c.

test = '12345'.

if test co '0123456789'.

write : 'only numericals'.

elseIF NOT TEST = SPACE.

write : 'ALPHA numericals'.

ELSE.

write : 'SPACE'.

ENDIF.

tHIS WORKS FINE FOR INPUT 12345

SOMETIMES MY INPUT IS LIKE THIS

test = '345 '. OR test = ' 345'.

HERE THE OUTPUT SHOULD BE ONLY NUMERICALS.

IN ORDER TO ACHEIVE THIS I DID CHANGED THIS

if test co '0123456789'.

TO if test co '0123456789 '.: NOTE AFTER 9 I ADDED A SPACE

NOW IT WORKS FINE FOR THIS CODE .

THE ONLY PROBLEM WITH CODE IS

EVEN IF TEST = ' '.

IT GIVES ME A OUT PUT SAYING ONLY NUMERICALS

IN THIS CASE I WANT O/P AS SPACE

CAN ANYONE TELL ME HOW TO ACHEIVE THIS

THANKS

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
433

Hi preety .

Try in this way...

test(5) type c.

test = '12345'.

<b>if test co '0123456789 ' and test NE ' '.</b>

write : 'only numericals'.

ELSEif test = SPACE.

write : 'SPACE'.

elseIF NOT TEST = SPACE.

write : 'ALPHA numericals'.

else.

write : 'Other'.

endif.

ENDIF.

<b>Reward Points if it is helpful.</b>

Let me know if you need more help.

Thanks & Regards

ilesh 24x7

2 REPLIES 2
Read only

Former Member
0 Likes
434

Hi preety .

Try in this way...

test(5) type c.

test = '12345'.

<b>if test co '0123456789 ' and test NE ' '.</b>

write : 'only numericals'.

ELSEif test = SPACE.

write : 'SPACE'.

elseIF NOT TEST = SPACE.

write : 'ALPHA numericals'.

else.

write : 'Other'.

endif.

ENDIF.

<b>Reward Points if it is helpful.</b>

Let me know if you need more help.

Thanks & Regards

ilesh 24x7

Read only

0 Likes
433

Thanks

Points awarded