CHANGESTR.REX: Difference between revisions
Content added Content deleted
m (updated some comments in this version of the BIF. -- ~~~~) |
m (condensed assignment of two null variables, changed some comments. -- ~~~~) |
||
Line 21: | Line 21: | ||
╚════════════════════════════╝ │ │ │ │ │ │ ╚═════════════════════════╝ |
╚════════════════════════════╝ │ │ │ │ │ │ ╚═════════════════════════╝ |
||
↓ ↓ ↓ ↓ ↓ ↓ */ |
↓ ↓ ↓ ↓ ↓ ↓ */ |
||
changestr: parse arg o,h,n,t,b,p /* |
changestr: parse arg o,h,n,t,b,p,$ f /*T,B,P are optional.*/ |
||
$='' /*$: the returned string.*/ |
|||
/*optional arguments ··· */ |
|||
t=word(t 999999999 , 1) /*maybe use the default? */ |
t=word(t 999999999 , 1) /*maybe use the default? */ |
||
b=word(b 1 , 1) /* " " " " */ |
b=word(b 1 , 1) /* " " " " */ |
||
Line 37: | Line 35: | ||
L=length(o) /*length of OLD string. */ |
L=length(o) /*length of OLD string. */ |
||
if L==0 & t\=0 then return n || h /*changing a null char? */ |
if L==0 & t\=0 then return n || h /*changing a null char? */ |
||
f='' /*first part of H if P>1. */ |
|||
if p\=1 then do /*if P ¬= 1, adjust F & H.*/ |
if p\=1 then do /*if P ¬= 1, adjust F & H.*/ |
||
f=left(h, min(p-1, length(h))) /*keep first part intact. */ |
f=left(h, min(p-1, length(h))) /*keep first part intact. */ |