Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

REXX Question about Numbers

2 views
Skip to first unread message

Ed Benoit

unread,
Dec 7, 2009, 6:33:51 PM12/7/09
to
Hello List,
How can I determine if a variable is a number or not? Is there a key word?


Ed.

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to LIST...@VM.MARIST.EDU with the message: INFO TSO-REXX

Steve Comstock

unread,
Dec 7, 2009, 6:51:21 PM12/7/09
to
The DATATYPE function can tell you. DATATYPE(string) returns
NUM if the string is a valid REXX number, and CHAR otherwise.


Kind regards,

-Steve Comstock
The Trainer's Friend, Inc.

303-393-8716
http://www.trainersfriend.com

� z/OS Application development made easier
��� * Our classes include
������ + How things work
������ + Programming examples with realistic applications
������ + Starter / skeleton code
������ + Complete working programs
������ + Useful utilities and subroutines
������ + Tips and techniques

==> call or email to receive a free sample student handout <==

Hayim Sokolsky

unread,
Dec 7, 2009, 6:53:03 PM12/7/09
to
Use DATATYPE( ).

DATATYPE(string) returns a value of NUM or CHAR. Note that a null string
returns CHAR.

Other formats: (all return 1 for true, and 0 for false)

DATATYPE(string,'N') - is a valid REXX number
DATATYPE(string,'W') - is a valid whole number
DATATYPE(string,'B') - is a binary number
DATATYPE(string,'X') - is a hex number

So you can code:

if datatype(num,'W') then say num 'is a whole number'


See TSO/E REXX Reference for more info.

Hayim
_____________________________________
Hayim Sokolsky, CISSP
Mainframe Security Architect
DTCC Corporate Information Security
18301 Bermuda Green Dr, MS 1-CIS
Tampa FL 33647-1760

Tel. (813) 470-2177

Ed Benoit <Ibm...@AOL.COM>
Sent by: TSO REXX Discussion List <TSO-...@VM.MARIST.EDU>
2009.12.07 18:33
Please respond to
TSO REXX Discussion List <TSO-...@VM.MARIST.EDU>


To
TSO-...@VM.MARIST.EDU
cc

Subject
[TSO-REXX] REXX Question about Numbers


Ed.

<BR>_____________________________________________________________
<FONT size=2><BR>
DTCC DISCLAIMER: This email and any files transmitted with it are
confidential and intended solely for the use of the individual or
entity to whom they are addressed. If you have received this email
in error, please notify us immediately and delete the email and any
attachments from your system. The recipient should check this email
and any attachments for the presence of viruses. The company
accepts no liability for any damage caused by any virus transmitted
by this email.</FONT>

Mickey

unread,
Dec 7, 2009, 7:07:55 PM12/7/09
to
If DATATYPE(myvar) ^= 'NUM' Then
Do
Say 'Something intelligent'
Exit 12
End

Mickey

--------------------------------------------------
From: "Ed Benoit" <Ibm...@AOL.COM>
Sent: Monday, December 07, 2009 3:33 PM
To: <TSO-...@VM.MARIST.EDU>


Subject: [TSO-REXX] REXX Question about Numbers

> Hello List,

Arthur T.

unread,
Dec 7, 2009, 8:52:43 PM12/7/09
to
On 7 Dec 2009 15:33:51 -0800, in bit.listserv.tsorexx
(Message-ID:<d20.5ed0d7...@aol.com>)
Ibm...@AOL.COM (Ed Benoit) wrote:

>How can I determine if a variable is a number or not? Is
>there a key word?

As others have said, you can use DATATYPE. Be aware of
surprising results. For instance, 1e6 will show as
datatype=num (it equals one million).

If you want to verify that a variable contains only digits
(and, maybe, signs or decimal points), you could use
DATATYPE followed by a VERIFY.

--
I cannot receive mail at the address this was sent from.
To reply directly, send to ar23hur "at" intergate "dot" com

Lizette Koehler

unread,
Dec 8, 2009, 7:45:19 AM12/8/09
to
Have you checked out DATATYPE to see if it does what you need?

Lizette


-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-...@VM.MARIST.EDU] On Behalf Of
Ed Benoit
Sent: Monday, December 07, 2009 6:34 PM
To: TSO-...@VM.MARIST.EDU
Subject: [TSO-REXX] REXX Question about Numbers

0 new messages