IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

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


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
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
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

Global Moderator


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

PostPosted: Wed May 09, 2007 5:36 pm
Reply with quote

Are you sure you reviewed all of the DATATYPE options?

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: 8797
Location: Welsh Wales

PostPosted: Wed May 09, 2007 5:41 pm
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Compile Several JCL JOB Through one r... CLIST & REXX 4
No new posts Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top