Escape A Loop

Discussion in 'Questions (Windows Mobile)' started by ceaser, Jan 9, 2009.

  1. ceaser

    ceaser Active Member Licensed User

    Hi

    In the following routine where the program tries to read a Total Station, how can I get the program to escape from this loop. :sign0085:"Button2" on another form calls this routine.

    Sub ReadStation(R,R1)
    ReadAgain:
    HVD(1)=0 :HVD(2)=0 :HVD(3)=0 :f=0
    If Main.DF(3)=1 Then
    'Leica Total Station
    suh(1)="21." :suh(2)="22." :suh(3)="31."
    If Main.DF(4)>=3 Then ' tc500,tc1010,tc1610
    If R="u" Then
    stcm="GET/M/WI11/WI21/WI22/WI31"
    Else If R="t" Then
    stcm="GET//WI11/WI21/WI22"
    If Main.DF(4)=3 OR Main.DF(4)=9 Then
    Serial1.Output("SET/160/0" & EndLine)
    End If
    End If
    Serial1.Output(stcm & EndLine)
    Else
    Serial1.Output(R & EndLine)
    End If
    A=Serial1.InputString
    'If Main.DF(4)<>9 Then Serial1.Output("?" & EndLine)
    Else If Main.DF(3)=6 Then
    'Sokkia
    Serial1.Output(su(R))
    End If
    If StrLength(A)<10 Then Goto ReadAgain

    'split the string up
    'Msgbox(A)
    Do
    f=f+1
    A1=(StrIndexOf(A,suh(f),0))
    If A1<>-1 Then
    HVD(f)=SubString(A,A1+7,8)
    If f=3 Then
    'distance
    HVD(f)=HVD(f)/1000
    Else
    'horizontal & vertical winkel
    HVD(f)=HVD(f)/100000
    End If
    End If
    Loop Until f=R1
    End Sub

    Thanks
    Michael
     
  2. MM2forever

    MM2forever Active Member Licensed User

    If i understand you right, then you should add an e.g boolean variable to your conditions that is changed by a button or something else... with every start of this routine the boolean has to be reseted.

    If StrLength(A)<10 and escape=False Then Goto ReadAgain

    Btw: Is this the thing you are dealing with? :Total station - Wikipedia, the free encyclopedia
     
    Last edited: Jan 9, 2009
  3. agraham

    agraham Expert Licensed User

    Gotos are so middle of last century :) Structure rules in the 21st millenium!

    Code:
    Do
      ...
      
    If ExitConditionIsMet Then Exit
      ...
    Loop While StrLength(A) < 10
    See Help->Main Help->Keywords->General
     
  4. MM2forever

    MM2forever Active Member Licensed User

    i also wanted to ask him why he isnt using a loop, but then I thought maybe because its freezing the app and maybe visual reading progress?

    ...Or am I wrong here :confused:
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    Gotos will not help with freezing issues.
    Two possible solutions are:
    - Use a Timer instead of a loop.
    - Add DoEvents (or Sleep(...) ) to your loop.
     
  6. ceaser

    ceaser Active Member Licensed User

    Thanks Guys:sign0188:

    That has shed some light on my problem.:)

    You are right MM2, that is the instrument that I use in my work. I have the Robotic Total Station (S6 from Trimble)

    Thanks
    Michael
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice