Highlighted
rjhodge379 Absent Member.
Absent Member.
1147 views

string::PadRight issues

The PadRight() method for strings only seems to work with hard coded numbers.

01 str1 as string value "hello".

01 str2 as string.

set str2 to str1::PadRight(10)   *> this works fine

declare pad as string = 10

set str2 to str1::PadRight(pad)   *> this doesn't work - no trailing spaces in returned string

Am I doing this wrong or is this a bug?

Randy Hodge

 

0 Likes
2 Replies
rjhodge379 Absent Member.
Absent Member.

RE: string::PadRight issues

Edit: The line should read:

declare pad as binary-long = 10

which is what I have in my code. I just typed it wrong in my post.

Randy Hodge

 

0 Likes
RobertSales Absent Member.
Absent Member.

RE: string::PadRight issues

Hi Randy, I tried compiling and running the following:

      01 str1 string value "hello".

      01 str2 string.

          set str2 to str1::PadRight(10)   *> this works fine

          display str2

          declare pad as binary-long = 10

          set str2 to str1::PadRight(pad)   *> this doesn't work - no trailing spaces in returned string

          display str2

Both of the display statements  showed "hello" followed by 5 spaces.  I think this is correct behaviour as the PadRight adds spaces up to the total length specified by the parameter.

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.