Results 1 to 14 of 14
  1. #1
    Bronze Lounger
    Join Date
    Sep 2007
    Posts
    1,203
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    	pcommConnMgr.autECLConnList.Refresh
    	intSessCount = pcommConnMgr.autECLConnList.Count
    	If intSessCount = 0 Then
    		Exit Sub
    	End If
    The above code works, but:

    I want to refresh and count, then check if zero. If it is zero, i would like to repeat the process a further 2 times, then exit sub if the count is still zero.

    I'd appreciate a little help with the syntax....

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Code:
    Dim i As Integer
    For i = 1 To 3
      pcommConnMgr.autECLConnList.Refresh
      intSessCount = pcommConnMgr.autECLConnList.Count
      If intSessCount > 0 Then
    	Exit For
      End If
    Next i
    If i = 4 Then
      Exit Sub
    End If
    If intSessionCount = 0 all 3 times, the loop counter i will be 1 higher than the upper limit 3 at the end.

  3. #3
    Bronze Lounger
    Join Date
    Sep 2007
    Posts
    1,203
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks Hans, what would I do without you?

    My Do until loop below is working ok, but has a danger of never ending (I [think] I have learned something today) Please would you check that my logic is correct in converting this to a for next loop with a maximum counter of 5.

    Code:
    If pcommPS.GetText(1, 2, 4) = "PROD" Then
    	Do Until pcommPS.GetText(3, 16, 52) = "x"
    		pcommPS.SendKeys "[clear]"
    		pcommOIA.WaitForAppAvailable 5
    		pcommOIA.WaitForInputReady
    	Loop
    	'Artificially end the loop
    	intLoop = intSessCount
    	booProcessed = True
    Else
    	booProcessed = False
    End If
    
    'Conversion to a For next loop with a max counter of 5
    
    If pcommPS.GetText(1, 2, 4) = "PROD" Then
    	For i = 1 To 5
    		If pcommPS.GetText(3, 16, 52) <> "x" Then
    			pcommPS.SendKeys "[clear]"
    			pcommOIA.WaitForAppAvailable 5
    			pcommOIA.WaitForInputReady
    				If pcommPS.GetText(3, 16, 52) = "x" Then
    					'Artificially end the loop
    					intLoop = intSessCount
    					booProcessed = True
    					Exit For
    				Else
    					booProcessed = False
    				End If
    		End If
    	Next i
    End If

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    I don't know what exactly the requirements are. Should you check that pcommPS.GetText(1, 2, 4) = "PROD" within the loop or isn't that necessary?

  5. #5
    Bronze Lounger
    Join Date
    Sep 2007
    Posts
    1,203
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Good catch. That If only needs to be evaluated once, outside the loop, but I do need to add an else "booProcessed = False" there.

  6. #6
    Bronze Lounger
    Join Date
    Sep 2007
    Posts
    1,203
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='VegasNath' post='788692' date='12-Aug-2009 20:08']Good catch. That If only needs to be evaluated once, outside the loop, but I do need to add an else "booProcessed = False" there.[/quote]

    Aah but...

    Will that be evaluated when the for-next loop is exited with "booProcessed = True"

  7. #7

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    If you use

    Code:
    If pcommPS.GetText(1, 2, 4) = "PROD" Then
    	For i = 1 To 5
    		If pcommPS.GetText(3, 16, 52) <> "x" Then
    			pcommPS.SendKeys "[clear]"
    			pcommOIA.WaitForAppAvailable 5
    			pcommOIA.WaitForInputReady
    				If pcommPS.GetText(3, 16, 52) = "x" Then
    					'Artificially end the loop
    					intLoop = intSessCount
    					booProcessed = True
    					Exit For
    				Else
    					booProcessed = False
    				End If
    		End If
    	Next i
    Else
      booProcessed = False
    End If
    you will only get booProcessed = True if pcommPS.GetText(1, 2, 4) = "PROD" AND pcommPS.GetText(3, 16, 52) = "x".

  9. #9

  10. #10
    Bronze Lounger
    Join Date
    Sep 2007
    Posts
    1,203
    Thanks
    0
    Thanked 0 Times in 0 Posts
    On testing, this is still a little off.

    If pcommPS.GetText(1, 2, 4) = "PROD"
    AND
    If pcommPS.GetText(3, 16, 52) = "x" on first evaluation, I am getting booProcessed = False, which should be true


    The logic is as follows:


    If pcommPS.GetText(1, 2, 4) <> "PROD" Then Get out, booProcessed = False. The End.

    If pcommPS.GetText(1, 2, 4) = "PROD"
    AND
    If pcommPS.GetText(3, 16, 52) = "x" Then Get Out, booProcessed = True. The End

    If pcommPS.GetText(1, 2, 4) = "PROD"
    AND
    If pcommPS.GetText(3, 16, 52) <> "x" Then
    pcommPS.SendKeys "[clear]"
    pcommOIA.WaitForAppAvailable 5
    pcommOIA.WaitForInputReady
    max 5 times UNTIL
    If pcommPS.GetText(1, 2, 4) = "PROD"
    AND
    If pcommPS.GetText(3, 16, 52) = "x" Then booProcessed = True, ELSE booProcessed = False

    Hope this makes sense.

  11. #11
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Try

    Code:
    booProcessed = False
    If pcommPS.GetText(1, 2, 4) = "PROD" Then
    	If pcommPS.GetText(3, 16, 52) = "x" Then
    		booProcessed = True
    	Else
    		For i = 1 To 5
    			pcommPS.SendKeys "[clear]"
    			pcommOIA.WaitForAppAvailable 5
    			pcommOIA.WaitForInputReady
    			If pcommPS.GetText(3, 16, 52) = "x" Then
    				'Artificially end the loop
    				intLoop = intSessCount ' What is this for?
    				booProcessed = True
    				Exit For
    			End If
    		Next i
    	End If
    End If

  12. #12
    Bronze Lounger
    Join Date
    Sep 2007
    Posts
    1,203
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ' What is this for?

    Hans, this is the count of available sessions. when we find one available session and use it, we are ensuring that the process is not carried out in the next available session.

    Thanks, slightly modified, this seems to work.

    Code:
    booProcessed = False
    If pcommPS.GetText(1, 2, 4) = "PROD" And pcommPS.GetText(3, 16, 52) = "x" Then
    	'Artificially end the loop
    	intLoop = intSessCount
    	booProcessed = True
    Else
    	For i = 1 To 5
    		pcommPS.SendKeys "[clear]"
    		pcommOIA.WaitForAppAvailable 5
    		pcommOIA.WaitForInputReady
    		If pcommPS.GetText(1, 2, 4) = "PROD" And pcommPS.GetText(3, 16, 52) = "x" Then
    			'Artificially end the loop
    			intLoop = intSessCount
    			booProcessed = True
    			Exit For
    		End If
    	Next i
    End If
    I am getting an occasional boot into non-responsive, but I cannot put my finger on why? It all steps through fine and gives the expected result.

  13. #13
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    I don't know the external application that you're using so I have no idea why it would become non-responsive.

  14. #14
    Bronze Lounger
    Join Date
    Sep 2007
    Posts
    1,203
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='HansV' post='788783' date='13-Aug-2009 13:51']I don't know the external application that you're using so I have no idea why it would become non-responsive.[/quote]

    I do, and I don't either.

    As always, Thanks for your help!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •