Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

To check whether the variable is a CHAR or NUM in Rexx

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
kaos

New User


Joined: 24 Apr 2007
Posts: 9
Location: Bangalore

PostPosted: Wed May 09, 2007 5:16 pm    Post subject: To check whether the variable is a CHAR or NUM in Rexx
Reply with quote

Hi,

I want to perform a check on the variable entered. The entered variable should be either a Numeric or Char or Varchar(0-9 or A-z)... No special chars allowed.
I used a function called DATATYPE('Var'), but that is giving a return code as CHAR when Special chars are entered.
Please let me know if there is some other built in function which can be helpful for me.
There is a function called COMAPRE(), but in which i should have the list of all the Special chars and if that is found in the string i can display a valid message.
I want to know if there is something else(easier) which can used for the above purpose.
Back to top
View user's profile Send private message

superk

Moderator Team Head


Joined: 26 Apr 2004
Posts: 4649
Location: Raleigh, NC, USA

PostPosted: Wed May 09, 2007 5:36 pm    Post subject: Re: To check whether the variable is a CHAR or NUM in Rexx
Reply with quote

Are you sure you reviewed all of the DATATYPE options?

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IKJ4A360/4.3.15?DT=20050714012324

Seems to me like DATATYPE('var',N) should match your first requirement and DATATYPE('var',A) should match your second requirement.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Wed May 09, 2007 5:41 pm    Post subject:
Reply with quote

I was going to say exactly the same as superk ........ until I tried a test.

Quote:
If you specify type, returns 1 if string matches the type; otherwise returns 0. If string is null, the function returns 0 (except when type is X, which returns 1 for a null string). The following are valid types. (Only the capitalized and highlighted letter is needed; all characters following it are ignored. Note that for the hexadecimal option, you must start your string specifying the name of the option with x rather than h.)


Code:

000001 /* REXX **/
000002                         
000003 ABC = "AB2"             
000004 A = DATATYPE(ABC,A)     
000005 SAY A                   
000006 ABC = "AB@"             
000007 A = DATATYPE(ABC,A)     
000008 SAY A                   


RESULT
Code:

1                                                         
     7 +++ A = DATATYPE(ABC,A)                             
Error running TESTPRO2, line 7: Incorrect call to routine 
***                                                       


Is this just me, or is it a general problem / technical glitch ???
Back to top
View user's profile Send private message
kaos

New User


Joined: 24 Apr 2007
Posts: 9
Location: Bangalore

PostPosted: Wed May 09, 2007 5:57 pm    Post subject: Re: To check whether the variable is a CHAR or NUM in Rexx
Reply with quote

Its workin for me.. but if the string has any of these !@#$^.? then it is giving an return code of 1 otherwise if others(%*-,) are usesd then its givein a returm code of 0.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Passing data from REXX to C programme... chong.zhou CLIST & REXX 3 Wed Jul 26, 2017 9:11 pm
No new posts REXX to get the all datasets name parasmalik20 CLIST & REXX 5 Tue Jul 18, 2017 9:10 pm
No new posts How system know which REXX to excute? jackzhang75 CLIST & REXX 14 Thu Jul 06, 2017 1:09 am
No new posts REXX - Dynamic file Creation d_sarlie CLIST & REXX 7 Tue Jun 27, 2017 7:30 pm
No new posts REXX WTO for console message bipinpeter CLIST & REXX 6 Tue Jun 27, 2017 3:56 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us