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

convert string to numeric

3,029 views
Skip to first unread message

Matan Cohen

unread,
Oct 28, 2010, 10:55:35 AM10/28/10
to
hi ,

I'm reading a string from a dataset using substr like this :
line = ' How can I convert this 000456 to a char '
number = word(line,6) -> here I used the word function but the idea is the
same


then i need to convert this number to a numeric so i could preform
arithmetic action on it ( plus , minus )
I can i do this ?


--
best regards,
matan cohen
MF System Administrator.

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

Walter Pachl

unread,
Oct 28, 2010, 11:00:20 AM10/28/10
to
number iS a number

line = ' How can I convert this 000456 to a char '
number = word(line,6)
say number+5


---- Matan Cohen <matanc...@GMAIL.COM> schrieb:

Robert Zenuk

unread,
Oct 28, 2010, 12:35:11 PM10/28/10
to
Just use your number variable...

/* rexx */


line = ' How can I convert this 000456 to a char '
number = word(line,6)

say number * 3

I got 1368...

Rob

In a message dated 10/28/2010 8:10:42 A.M. US Mountain Standard Time,

Mickey

unread,
Oct 28, 2010, 4:04:28 PM10/28/10
to
There is NO datatyping in Rexx. The contents of a variable at the time you
ask defines it. So, While MY_VAR may contain the value XXX, if I assignit a
value of 123, I can perform numeric operations on it.

--------------------------------------------------
From: "Matan Cohen" <matanc...@GMAIL.COM>
Sent: Thursday, October 28, 2010 10:54 AM
To: <TSO-...@VM.MARIST.EDU>
Subject: [TSO-REXX] convert string to numeric

Bob Bridges

unread,
Oct 28, 2010, 11:24:11 PM10/28/10
to
While "no datatyping" is correct technically, I gather that in fact all data
in REXX is stored as character strings, right? I mean, the 6th word is the
character string '000456', and if you then performed this statement:

xyz=number+1

...xyz would then contain the character string '457'. Right?

---
Bob Bridges, rhb...@attglobal.net, cell 336 382-7313
work bob.b...@libertymutual.com, 317 581-6487

/* If you read the New Testament with an Old-Covenant heart, it will be just
Law to you. Likewise, if you read the Old Testament with a New-Covenant
heart, you will see Christ in all of it. -Rick Joyner, "The Apostolic
Ministry" */

-----Original Message-----
From: Mickey
Sent: Thursday, October 28, 2010 16:04

There is NO datatyping in Rexx. The contents of a variable at the time you
ask defines it. So, While MY_VAR may contain the value XXX, if I assignit a
value of 123, I can perform numeric operations on it.

--------------------------------------------------
From: "Matan Cohen" <matanc...@GMAIL.COM>
Sent: Thursday, October 28, 2010 10:54 AM

> I'm reading a string from a dataset using substr like this :


> line = ' How can I convert this 000456 to a char '
> number = word(line,6) -> here I used the word function but the idea is the
> same
>
> then i need to convert this number to a numeric so i could preform
> arithmetic action on it ( plus , minus )

----------------------------------------------------------------------

adrianstern

unread,
Oct 29, 2010, 6:11:03 AM10/29/10
to
On Oct 28, 11:24 pm, rhbr...@ATTGLOBAL.NET (Bob Bridges) wrote:
> While "no datatyping" is correct technically, I gather that in fact all data
> in REXX is stored as character strings, right?  I mean, the 6th word is the
> character string '000456', and if you then performed this statement:
>
> xyz=number+1
>
> ...xyz would then contain the character string '457'.  Right?
>
> ---
> Bob Bridges, rhbr...@attglobal.net, cell 336 382-7313
>   work bob.brid...@libertymutual.com, 317 581-6487

>
> /* If you read the New Testament with an Old-Covenant heart, it will be just
> Law to you.  Likewise, if you read the Old Testament with a New-Covenant
> heart, you will see Christ in all of it.  -Rick Joyner, "The Apostolic
> Ministry" */
>
>
>
> -----Original Message-----
> From: Mickey
> Sent: Thursday, October 28, 2010 16:04
>
> There is NO datatyping in Rexx. The contents of a variable at the time you
> ask defines it. So, While MY_VAR may contain the value XXX, if I assignit a
> value of 123, I can perform numeric operations on it.
>
> --------------------------------------------------
> From: "Matan Cohen" <matancohen...@GMAIL.COM>

> Sent: Thursday, October 28, 2010 10:54 AM
>
> > I'm reading a string from a dataset using substr like this :
> > line = ' How can  I convert this 000456 to a char '
> > number = word(line,6) -> here I used the word function but the idea is the
> > same
>
> > then i need to convert this number to a numeric so i could preform
> > arithmetic action on it ( plus , minus )
>
> ----------------------------------------------------------------------
> For TSO-REXX subscribe / signoff / archive access instructions,
> send email to LISTS...@VM.MARIST.EDU with the message: INFO TSO-REXX- Hide quoted text -
>
> - Show quoted text -

that's correct - the result is "numeric" but in fact still a string in
a numeric format - no datatyping means you never have to predefine
what can be stored in a variable, but certain operations will crash at
run-time if not possible using the current contents of the variables
I seem to remember a language (could it have been Mantis?) where any
string containing anything numeric could be used in a computation, the
language "stripped off" the non-numeric part so that "this is 1" +
"that is 2" gave the answer 3!

Mickey

unread,
Oct 30, 2010, 11:47:20 AM10/30/10
to
That is correct. Rexx treats everything like a string

Mickey

--------------------------------------------------
From: "Bob Bridges" <rhb...@ATTGLOBAL.NET>
Sent: Thursday, October 28, 2010 11:23 PM
To: <TSO-...@VM.MARIST.EDU>
Subject: Re: [TSO-REXX] convert string to numeric

0 new messages