Groups | Search | Server Info | Keyboard shortcuts | Login | Register


Groups > comp.lang.basic.misc > #318

Re: need a code bit

From ArarghMail208NOSPAM@NOT.AT.Arargh.com
Newsgroups comp.lang.basic.misc
Subject Re: need a code bit
Date 2012-09-04 13:43 -0500
Organization Ripco Communications Inc.
Message-ID <tbic48pid0uisemh7mpq6sn2ek0df3l5j3@4ax.com> (permalink)
References <XnsA0BA3AC6BDBB0gandalfparker@88.198.244.100> <XnsA0BA662985320auricauricauricauric@88.198.244.100> <u2r5489qapdoqvqdk9vilrhfdjh9napph5@4ax.com> <6c5b4ea8-a6ec-4ad9-ba2d-b0367ca8c94d@z17g2000yqk.googlegroups.com>

Show all headers | View raw


On Sun, 2 Sep 2012 02:09:47 -0700 (PDT), "news@rtrussell.co.uk"
<news@rtrussell.co.uk> wrote:

>On Sep 2, 6:31 am, ArarghMail208NOS...@NOT.AT.Arargh.com wrote:
>> If I were to code that routine in MS basic, it would look somewhat
>> like:
>>
>>    FOR N=1 TO LEN(what$)
>>       if mid$(what$,n,1)=lookfor$ then mid$(what$,n,1)=replacewith$
>>    next n
>
>Using a FOR...NEXT loop is likely to be slow compared with using
>INSTR, especially if there are only a few occurrences of lookfor$ in
>what$.  
True - didn't think of that.  

Just checked the old ASM routine, and that basically how it was done
- the routine after the regs are set up:

LoopHere:
        repne   scasb es:[di]          ; look for it
        jne     @f
        mov     es:[di]-1,ah
@@:     jcxz   Exit                    ; any string left?
        jmp     LoopHere                ; yep - look some more
Exit:   ret

And in MS's basics: have to use DO & LOOP in place of REPEAT & UNTIL

>This is how I would code it in BBC BASIC:
>
>  REPEAT
>    n% = INSTR(what$,lookfor$)
>    IF n% THEN MID$(what$,n%,1) = replacewith$
>  UNTIL n%=0
>
>There's no iteration at all if what$ doesn't contain lookfor$.

-- 
ArarghMail208 at [drop the 'http://www.' from ->] http://www.arargh.com
BCET Basic Compiler Page: http://www.arargh.com/basic/index.html

To reply by email, remove the extra stuff from the reply address.

Back to comp.lang.basic.misc | Previous | NextPrevious in thread | Find similar


Thread

need a code bit Gandalf  Parker <gandalf@the.dead.ISP.of.Community.net> - 2012-08-25 12:46 +0000
  Re: need a code bit "Auric__" <not.my.real@email.address> - 2012-08-25 17:02 +0000
    Re: need a code bit Gandalf  Parker <gandalf@the.dead.ISP.of.Community.net> - 2012-08-26 13:39 +0000
      Re: need a code bit "Auric__" <not.my.real@email.address> - 2012-08-26 16:23 +0000
        Re: need a code bit Gandalf  Parker <gandalf@the.dead.ISP.of.Community.net> - 2012-08-28 12:04 +0000
    Re: need a code bit ArarghMail208NOSPAM@NOT.AT.Arargh.com - 2012-09-02 00:31 -0500
      Re: need a code bit "news@rtrussell.co.uk" <news@rtrussell.co.uk> - 2012-09-02 02:09 -0700
        Re: need a code bit Gandalf  Parker <gandalf@the.dead.ISP.of.Community.net> - 2012-09-02 14:09 +0000
          Re: need a code bit "news@rtrussell.co.uk" <news@rtrussell.co.uk> - 2012-09-07 04:01 -0700
            Re: need a code bit Ben Yates <winston19842005@yahoo.com> - 2012-09-07 15:29 -0700
              Re: need a code bit "news@rtrussell.co.uk" <news@rtrussell.co.uk> - 2012-09-09 10:37 -0700
        Re: need a code bit ArarghMail208NOSPAM@NOT.AT.Arargh.com - 2012-09-04 13:43 -0500

csiph-web