Post Reply 
Padding a string with spaces
03-04-2015, 06:11 AM (This post was last modified: 03-04-2015 08:57 AM by bobkrohn.)
Post: #12
RE: Padding a string with spaces
(03-04-2015 04:09 AM)Mark Hardman Wrote:  Sorry about that. I've put strike-through on my previous post.

I appears that this left pad "trick" is less useful than I thought.

What's to be sorry about!?
Your exhibiting "thinking outside the box" which is a G-O-O-D thing.
I will still fiddle around with it as I hope others will too.
Have fun.

Here's what I came up with so far.

PHP Code:
EXPORT PadLR(MyStr,MyLen,LorR
BEGIN 

LOCAL i
,s;  
s:="";

// True  = -LorR = Left
// False = +LorR = Right
//     0 =       = Centered
//                 typ use Even MyLen 

IF LorR 0 THEN
  REPLACE
("",MyLen DIM(MyStr),MyStr)▶MyStr
END;

IF 
LorR 0 THEN
  REPLACE
(MyStr,MyLen 1,"")▶MyStr
END;

IF 
LorR == 0 THEN
  
FOR i FROM 1 TO (MyLen-DIM(MyStr))/DO
    
:= " "
  
END;
  
MyStr s ▶ MyStr;
END;

RETURN 
MyStr;

END
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Padding a string with spaces - Joe Horn - 03-02-2015, 07:20 AM
RE: Padding a string with spaces - Angus - 03-03-2015, 08:02 AM
RE: Padding a string with spaces - Han - 03-03-2015, 05:08 PM
RE: Padding a string with spaces - bobkrohn - 03-04-2015 06:11 AM
RE: Padding a string with spaces - Angus - 03-04-2015, 05:43 AM



User(s) browsing this thread: 1 Guest(s)