gettingstarted
[Top] [All Lists]

Re: gettingstarted Digest, Vol 2, Issue 24

To: gettingstarted at lists dot realsoftware dot com
Subject: Re: gettingstarted Digest, Vol 2, Issue 24
From: Aubrey Todd <atodd at copper dot net>
Date: Thu, 27 May 2004 18:52:07 -0700
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: <20040527221525 dot 5B3F21EC1E5 at lists dot realsoftware dot com>

Yes, I am stepping through the Debugger watching the numbers change.

  If Pos>1 Then
     perform some process here
    End If
'Perform some process here' has another If-then statement which only activates with a string like "+3(" in the first loop and ")3+" in the second loop. In each loop the Debugger jumps from the second If-then statement to the 'Loop Until Pos=0' step and nothing is processed in-between.

After posting the original problem, I rechecked ProbStr=(2+1/2)+(3+1/4), and it has the same problem. You can watch the value of Pos reset to a smaller value in the debugger. If you try just (2+1/2), it works fine.

I have no idea of where to go from here.

Aubrey

Message: 8
Subject: InStr problems
From: Aubrey Todd <atodd at copper dot net>
Date: Thu, 27 May 2004 11:41:04 -0700


I am having a problem with the InStr command in the following code:

   Dim Pos as Integer

   //Check for Justaposition on the left
  //Checks for a number before the '(' and inserts a '*' if appropriate
   Pos=-1
   Do //This loop works fine
     Pos=Pos+2
     Pos=InStr(Pos,ProbStr,"(")
     If Pos>1 Then
      perform some process here
     End If
   Loop Until Pos=0

   //Check for Justaposition on the right
  //Checks for a number after the ')' and inserts a '*' if appropriate
   Pos=-1
   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

ProbStr is a string property.
If ProbStr=(2+1/2)+(3+1/4) both loops work correctly.
If ProbStr=Dec(2+1/2)+Dec(3+1/4), the second loop does not exit because
Pos never goes to zero.
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. If
I manually change the command to Pos=InStr(23,ProbStr,")"), it works
fine and returns a zero.

Anyone have a hint as to what I am doing wrong or why it does not work?

Thanks,
Aubrey
PB G4 Mac OS 10.3.3
RB 5.2.4




==================================================

Message: 9
Subject: Re: InStr problems
From: "Joseph J. Strout" <joe at realsoftware dot com>
Date: Thu, 27 May 2004 13:47:48 -0500

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

_______________________________________________
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>