Guidance
指路人
g.yi.org
Guidance Forums / Reginald Rexx / Literal strings composed of numeric digits

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. Literal strings composed of numeric digits
#13616
Posted by: DougA 2012-08-27 23:39:04 Last edited by: DougA 2012-08-27 23:40:31 (Total edited 1 time)
When I try to set the following literal, any preceeding zeros are removed.

Qual = '01'      (or '0000123' etc)

Results in "1"  or "123"


According to the documentation:

  "A literal string is any text enclosed within single or double quotation marks (ie, ' or "). It makes no difference whether you use single or double quotation marks, as long as the opening quotation mark is the same as the ending mark. REXX uses all of the text enclosed within the quotation marks exactly as you typed it (ie, upper and lower case, as well as blank space, is preserved). REXX doesn't ignore the text like with a comment, but neither does REXX try to evaluate the text (ie, replace it with some "value") like with a variable or mathematical expression."

I'm suprised I haven't run into this before, is it supposed to work this way ?
Doug
Message2.
#13617
Posted by: Jeff Glatt 2012-09-02 01:58:57
Yes, that's how rexx works. Numbers can be with or without quotes. If you have all numeric characters (0 to 9), then it's a number. Leading zeroes are discarded. The value is clipped to the NUMERIC DIGITS setting. Notice in RPC's syntax coloring, "123" is the color of a number, not a literal string like "hello".

Use the FORMAT() function (Math -> Math operations) to pad with spaces for the purpose of displaying a number to a particular width. And run that through CHANGESTR if you want zeroes instead.

SAY CHANGESTR(" ", FORMAT("123", 6), "0")
Message3.
#13618
Posted by: DougA 2012-09-06 02:58:39
This I could understand, IF, I wanted a number, but I don't understand why Rexx should make that dermination at literal assign.   That breaks the "uses all of the text enclosed within quotations marks exactly"  and the "neither does Rexx try to evaluate the text" ... both are actually being done.

Oddly,  (thankfully), it's not consistant
a = right('001',3)
b = left('001',3)
Parse value '001' with c
Say a b c
Gives:   001 001 001
all set the var to '001'  and it stays that way unless some numeric operation is performed (that would be as expected)

so, only a = '001'  sets a to '1'
I just don't see why a literal assignment (with quotes) is presumed to be numeric and modified, if it contains digits when there's no numeric operation going on.
Doug
Message4. Without being able to confirm it (not being at work)
#13619
Posted by: Michael S 2012-09-08 15:33:05
I'll take a bet that's the same behavior as Rexx on the mainframe. Whenever I run into your problem, I simply append a leading 'A' to the string, do whatever I want to, and then remove it afterwards.
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Fri 2024-3-29  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0