jed-users mailing list

[2002 Date Index] [2002 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

Re: Re: Re: SLang tab completion - update 2002-08-05


----- Original Message ----- 
From: "John E. Davis" <davis@xxxxxxxxxxxxx>
To: <jed-users@xxxxxxxxxxx>; <jed-users@xxxxxxxxxxx>
Sent: Friday, August 09, 2002 12:38 AM
Subject: Re: Re: Re: SLang tab completion - update 2002-08-05


> Paul <p.boekholt@xxxxxxxxx> wrote:
> >I'm using S-lang 1.4.0 and I don't have a strreplace()....how do I
> >implement it in S-lang?
> ... or some other person
> if you want to take shot at an implementation. ...

Here's my shot:

define strreverse( s)
{
   variable r= "";
   
   foreach ( s) r= char(()) +r;

   return r;
}

define strreplace( s, a, b, n)
{
   variable j, h, l, m, i;
   
   if ( j= (n < 0), j)
     {
        s= strreverse( s);
        a= strreverse( a);
        b= strreverse( b);
        n= -n;
     }

   h= s; s= ""; l= strlen(a); m= 0;
   loop (  n)
     {
        if ( i= is_substr( h, a), not i) break;
        s+= substr( h, 1, i-1) +b;
        h= substr( h, i+l, -1);
        m++;
     }
   s+= h;

   if ( j) s= strreverse( s);
   
   return ( s, m);
}

Hope it helps.

Klaus


--------------------------
To unsubscribe send email to <jed-users-request@xxxxxxxxxxx> with
the word "unsubscribe" in the message body.
Need help? Email <jed-users-owner@xxxxxxxxxxx>.


[2002 date index] [2002 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]