Warum wollt Ihr denn partout die Räder neu erfinden!

Kopiert doch einfach den folgenden Source Code, der eine Kopie der Funktionen WRAPTEXT und REPLACE (wird aus WRAPTEXT aufgerufen) von Michael Sansosterra enthält in eine Quelle, wandelt das Ding mit 14 in ein Programm um und führt es aus!

Code:
D WrapText        PR         12288                                   
D  UnfText                    8192    Varying Const Options(*VarSize)
D  LineLen                       5  0 Const                          
D  LineBreak                    10    Varying Const Options(*NoPass) 
                                                                     
DReplace          PR          8192    Varying                        
D parmSearchStr               8192    Varying Const Options(*VarSize)
D FindStr                     8192    Varying Const Options(*VarSize)
D ReplaceStr                  8192    Varying Const Options(*VarSize)
 //******************************************************************
D OrigText        S            250A   Varying                        
                                                                     
D DSText          DS                  Qualified                      
D   Text1                       52A                                  
D   Text2                       52A                                  
D   Text3                       52A                                  
D   Text4                       52A                                  
D   Text5                       52A                                  
D   Text6                       52A                                  
D   FGText                      52A   Dim(6) Overlay(DSText)         

                                                                         
D Index           S              3U 0                                    
 //**********************************************************************
 /Free                                                                   
    OrigText = 'Wieso sollte die Funktion WRAPTEXT von Michael +         
                Sansosterra den Erfordernissen nicht entsprechen? +      
                M.E. ist dies genau was gefordert wurde. +               
                Man muss dieses Programm, das eine Kopie der +           
                Funktion enthält umwandeln, ausführen +                  
                und das Ergebnis anschauen!';                            
                                                                         
    DSText = WrapText(OrigText: %Len(DSText.Text1));                     
    For Index = 1 to %Elem(DSText.FGText);                               
        Dsply DSText.FGText(Index);                                      
    EndFor;                                                              
                                                                         
  *InLR       = *On;                                                     
 /END-FREE                                                               
 //**********************************************************************
P WrapText        B                                                      
                                                                          
D WrapText        PI         12288                                        
D  UnfText                    8192    Varying Const Options(*VarSize)     
D  LineLen                       5  0 Const                               
D  LineBreak                    10    Varying Const Options(*NoPass)      
 // Work Fields                                                           
D WrkText         s            + 1    Like(UnfText)                       
D LineText        s          12288                                        
D WordText        s                   Like(UnfText)                       
D FmtText         s          12288                                        
D WordLen         s              5  0                                     
 // Word/Line counters                                                    
D Line            s              5  0                                     
D Word            s              5  0                                     
 //-----------------------------------------------------------------------
 /Free                                                                    
    WrkText=%TrimL(UnfText)+' ';                                          
    If %Parms>=3;                                                         
        If %Len(LineBreak)>0;                                             
            WrkText=Replace(WrkText:LineBreak:' '+LineBreak+' ');         
        EndIf;                                                     
    EndIf;                                                         
                                                                   
    If LineLen<=*Zero Or LineLen>%Size(UnfText);                   
        Return 'INVALID LEN*';                                     
    EndIf;                                                         
                                                                   
    If UnfText=*Blank;                                             
        Return '';                                                 
    EndIf;                                                         
                                                                   
    Dow %Len(WrkText)>*Zero;                                       
                                                                   
        // Find Boundary of word                                   
        WordLen=%Scan(' ':WrkText)-1;                              
                                                                   
        If WordLen>*Zero;                                          
                                                                   
            // Test if Word length is greater than the wrap length 
            If WordLen>LineLen ;                                   
                WordText=%Subst(WrkText:1:LineLen);                       
                WrkText=%Subst(WrkText:LineLen+1);                        
            Else;                                                         
                WordText=%Subst(WrkText:1:WordLen);                       
                WrkText=%TrimL(%Subst(WrkText:WordLen+1));                
            EndIf;                                                        
                                                                          
            // Test if break was requested                                
            If %Parms=3;                                                  
                If WordText=LineBreak;                                    
                    WordText=' ';                                         
                    ExSr BuildLine;                                       
                EndIf;                                                    
            EndIf;                                                        
                                                                          
            // If Length of Current Line + Length of the current word     
            // > than formatted line length, make a new line              
            If     %Len(%TrimR(LineText)) + %Len(WordText)+1>LineLen      
               And %Len(%TrimR(LineText))>0;                              
               ExSr BuildLine;                                            
            EndIf;                                                  
                                                                    
            //  Append Word to current Line                         
            //  NOTE: Word will be blank if a line break specified  
            If WordText<>*Blanks;                                   
                Word=Word+1;                                        
                If Word=1;                                          
                    LineText=WordText;                              
                Else;                                               
                    LineText=%TrimR(LineText)+' '+WordText;         
                EndIf;                                              
            EndIf;                                                  
                                                                    
        EndIf;                                                      
    EndDo;                                                          
                                                                    
    // Build Remaining Line                                         
    If LineText<>*blanks;                                           
        ExSr BuildLine;                                             
    EndIf;                                                          
                                                                          
   Return FmtText;                                                        
                                                                          
   // Build Single Line according to the requested format width           
   BegSr BuildLine;                                                       
       Word=*Zero;                                                        
       If Line=*Zero;                                                     
           FmtText=%Subst(LineText:1:LineLen);                            
       Else;                                                              
           If LineLen*Line>%Size(FmtText);                                
               LeaveSr;                                                   
           Else;                                                          
               FmtText=%Subst(FmtText:1:LineLen*Line) +                   
                       %Subst(LineText:1:LineLen);                        
           EndIf;                                                         
       EndIf;                                                             
       Line=Line+1;                                                       
                                                                          
       LineText=*Blank;                                                   
   EndSr;                                                                 
                                                                          
 /End-Free                                                            
P WrapText        E                                                   
 //*******************************************************************
 // Find and Replace a string                                         
 //*******************************************************************
PReplace          B                                                   
DReplace          PI          8192    Varying                         
D parmSearchStr               8192    Varying Const Options(*VarSize) 
D FindStr                     8192    Varying Const Options(*VarSize) 
D ReplaceStr                  8192    Varying Const Options(*VarSize) 
                                                                      
D SearchStr       S           8192    Varying Static                  
                                                                      
D Pos             S              5i 0                                 
D SL              S              5i 0                                 
D FL              S              5i 0                                 
                                                                      
 /Free                                                                
    SearchStr=parmSearchStr;                                          
                                                                      
    FL=%Len(FindStr);                                            
    Pos=*zero;                                                   
                                                                 
    Dow pos + fl<=%Len(SearchStr);                               
        SL=pos+1;                                                
        Pos=%Scan(FindStr:SearchStr:sl);                         
                                                                 
        // Leave if search string isn't found                    
        If Pos=*Zero;                                            
            Leave;                                               
        EndIf;                                                   
                                                                 
        // Build new string with replaced text in the middle     
        If Pos + fl > %Len(SearchStr);                           
            SearchStr=%Subst(SearchStr:1:Pos-1) + ReplaceStr;    
        Else;                                                    
             SearchStr=%Subst(SearchStr:1:Pos-1) + ReplaceStr +  
                       %Subst(SearchStr:Pos + fl);               
        EndIf;                                                   
                                                                 
        // Set starting position for search of next occurance     
        Pos=Pos+%Len(ReplaceStr)-1;                               
    EndDo;                                                        
                                                                  
    Return SearchStr;                                             
 /End-Free                                                        
P Replace         E
Birgitta