Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.programming > #7007

Re: A problem about programming

From Richard Heathfield <rjh@cpax.org.uk>
Newsgroups comp.programming
Subject Re: A problem about programming
Date 2016-11-24 12:08 +0000
Organization Fix this later
Message-ID <o16l5o$em5$1@dont-email.me> (permalink)
References (1 earlier) <o1500m$m4q$1@dont-email.me> <mn.bd4e7e0be141a73c.142705@Kiss-the-Sphinx> <o16c26$eqd$1@dont-email.me> <mn.c2a67e0b772051a3.142705@net.com> <mn.c3017e0bbb5b6a7b.142705@net.com>

Show all headers | View raw


On 24/11/16 11:49, Lino wrote:
> Dopo dura riflessione, Lino ha scritto :
>> Scriveva Richard Heathfield giovedì, 24/11/2016:
>>> On 23/11/16 21:38, Lino wrote:
>>> <snip>
>>>>
>>>> this (below) work partially and it have 2 problem:
>>>>
>>>>        st.Ticker= "IT_"+StrRight(ticker,Lenght+3);
>
>>> I think you mean "Length", not "Lenght".
>
>
> aaaaaaaaarghhhhhhhhhhhh
>
> now the problem of "cycle For" is resolved. All symbols is changed on
> apply.
>
> :)
>
> ------
>
>
>
> but remain the 2nd problem the "lenght of string" that isin't the same
> for all symbols

That is why I gave the rather longer solution in my most recent post. It 
was designed to work with any length inputs. (Whether it /does/ work 
with any length inputs isn't something I can test here, since I don't 
have AFL.)

If it /does/ work, you might want to consider turning it into a 
parameterised user-defined function, so that you don't have to solve the 
same problem again should it arise in a different context.

I don't know the syntax for AFL user-defined functions, but I would 
imagine it would look something like this:

// replace_first(): in the string s, search
// for the first occurrence of old. If found,
// return a string in which old is replaced with new.
// Otherwise, return the empty string.

function replace_first(s, old, new)
{
   result = "";
   left = "";
   centre = new;
   right = "";
   startpos = StrFind(s, old); // where is the old string?
   if(startpos > 0) // we have a match
   {
     if(startpos > 1) // we need to save the part before the match
     {
       left = StrLeft(s, startpos); // first part saved
     }

     // now we need to save the part /after/ the match.
     // The part after the match will be the length of the string,
     // LESS the length of the bit you want to get rid of, LESS
     // the length of the part we already accounted for.

     rightlength = StrLen(s) - StrLen(old) - StrLen(left);

     // Now we can save the part after the match

     right = StrRight(s, rightlength);

     // The easy bit: adding together all the bits we want to keep.

     result = left + centre + right;
   }
   return result;
}

-- 
Richard Heathfield
Email: rjh at cpax dot org dot uk
"Usenet is a strange place" - dmr 29 July 1999
Sig line 4 vacant - apply within

Back to comp.programming | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

A problem about programming Lino <lino@net.com> - 2016-11-23 19:09 +0100
  Re: A problem about programming Richard Heathfield <rjh@cpax.org.uk> - 2016-11-23 19:36 +0000
    Re: A problem about programming Lino <lino@net.com> - 2016-11-23 21:04 +0100
    Re: A problem about programming Lino <lino@net.com> - 2016-11-23 23:38 +0100
  Re: A problem about programming Richard Heathfield <rjh@cpax.org.uk> - 2016-11-23 21:01 +0000
    Re: A problem about programming Richard Heathfield <rjh@cpax.org.uk> - 2016-11-23 21:02 +0000
    Re: A problem about programming Lino <lino@net.com> - 2016-11-23 22:38 +0100
      Re: A problem about programming Lino <lino@net.com> - 2016-11-23 22:40 +0100
      Re: A problem about programming Richard Heathfield <rjh@cpax.org.uk> - 2016-11-24 09:33 +0000
        Re: A problem about programming Lino <lino@net.com> - 2016-11-24 11:18 +0100
          Re: A problem about programming Lino <lino@net.com> - 2016-11-24 12:49 +0100
            Re: A problem about programming Richard Heathfield <rjh@cpax.org.uk> - 2016-11-24 12:08 +0000
        Re: A problem about programming Lino <lino@net.com> - 2016-11-24 14:08 +0100
        Re: A problem about programming BartC <bc@freeuk.com> - 2016-11-24 17:14 +0000
          Re: A problem about programming Richard Heathfield <rjh@cpax.org.uk> - 2016-11-24 17:18 +0000

csiph-web