gettingstarted
[Top] [All Lists]

Re: InStr problems

To: Getting Started <gettingstarted at lists dot realsoftware dot com>
Subject: Re: InStr problems
From: "Joseph J. Strout" <joe at realsoftware dot com>
Date: Thu, 27 May 2004 13:47:48 -0500
Delivered-to: gettingstarted at lists dot realsoftware dot com
List-help: <mailto:gettingstarted-request@lists.realsoftware.com?subject=help>
List-id: Getting Started <gettingstarted.lists.realsoftware.com>
List-post: <mailto:gettingstarted@lists.realsoftware.com>
References: <20040527170005 dot C3E161EA461 at lists dot realsoftware dot com> <688CAD44-B00D-11D8-8080-000393DBA370 at copper dot net>
At 11:41 AM -0700 5/27/04, Aubrey Todd wrote:

  Do //This loop does not work all the time
    Pos=Pos+2
    Pos=InStr(Pos,ProbStr,")") //<===Problem occurs here
    If Pos>1 Then
     perform some process here
    End If
  Loop Until Pos=0
...
In the second loop, Pos=InStr(Pos,ProbStr,")")=21 the second time through, then loop and Pos=Pos+2=23, but when it hits Pos=InStr(Pos,ProbStr,")") again, Pos is set to 21 instead of zero.

You've verified this by stepping through it with the debugger?

If I manually change the command to Pos=InStr(23,ProbStr,")"), it works fine and returns a zero.

In that case, there has to be a some sort of confusion here; there is no difference to InStr between a literal 23 and a variable which contains 23.

My guess is that the second time through the loop, Pos is not actually equal to 21. Perhaps "perform some process here" is accidentally clobbering the value of Pos.

Best,
- Joe

--
,------------------------------------------------------------------.
|    Joseph J. Strout           REAL Software, Inc.                |
|    joe at realsoftware dot com       http://www.realsoftware.com        |
`------------------------------------------------------------------'
_______________________________________________
Unsubscribe or switch delivery mode:
<http://support.realsoftware.com/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>