Jump to content

how to stop FOR


Recommended Posts

Hi, i have a for and can't stop it,

using ExitLoop i don't see any reaction..

For $oLink in $oLinks
  $check = _StringBetween($oLink.href, $x1, $y1)
  If not @error Then
   $string=_ArrayToString($check)
   If $a = $string Then
    ExitLoop ; ==> HERE NEED TO STOP
   ElseIf $a < 9 Then
    $result = StringLeft($string, 1)
   Else
    $result = StringLeft($string, 2)
   EndIf
  EndIf
Next
; ==> HERE need to go, by ignoring all rest of $oLinks

Thanks alot

Edited by toader

[center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Don't utter a single word[/font][/center][center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Just shut your pretty mouth[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you again[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you[/font][/center][center][font=courier new,courier,monospace]In hell[/font][/center]

Link to comment
Share on other sites

i think here is some bug, problem is not in code,

coz i test it on separated script everything works well :oops:

i try now "If $x <> $y" also don't work.... ahh..

Func _Repeat()
$a = $a+1
ConsoleWrite('$a = '&$a)
_IELoadWait($oIE)
$oLinks = _IELinkGetCollection($oIE)
$iNumLinks = @extended
ConsoleWrite('  2. Links Found: ' & $iNumLinks)
If $a <> $b Then
  For $oLink in $oLinks
   FileWrite($mFile, $oLink.href & @CRLF)
   $check = _StringBetween($oLink.href, $x1, $y1)
   $check = _StringBetween($oLink.href, $x2, $y2)
   If not @error Then
    $string=_ArrayToString($check)
    If $a < 9 Then
     $result = StringLeft($string, 1)
    Else
     $result = StringLeft($string, 2)
    EndIf
    If $result > $a Then
     ConsoleWrite (' I found it: '&$result& ' link: ' & $oLink.href & @CRLF)
     _Repeat()
    Elseif $result = $a Then
     MsgBox(0,'ERROR','$result = $a'&$result&'='&$a)
    EndIf
   EndIf
  Next
Else
  ConsoleWrite('$a is equal with $b'&$a&'='&$b)
EndIf
EndFunc

In console i see all is well:

$a = 13  2. Links Found: 38 I found it: 14 link: ..b=14
$a = 14  2. Links Found: 43 I found it: 15 link: ..b=15
$a = 15  2. Links Found: 40 I found it: 16 link: ..b=16
$a = 16  2. Links Found: 25
$a is equal with $b16=16
--> COM Error Encountered in test2.au3
----> $IEComErrorScriptline = 33
----> $IEComErrorScriptline = 34
----> $IEComErrorScriptline = 35
...

This IE errors is in "If $a <> $b Then" and in this tipe $a = $b

Line 33,34,35:

FileWrite($mFile, $oLink.href & @CRLF)
   $check = _StringBetween($oLink.href, $x1, $y1)
   $check = _StringBetween($oLink.href, $x2, $y2)
Edited by toader

[center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Don't utter a single word[/font][/center][center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Just shut your pretty mouth[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you again[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you[/font][/center][center][font=courier new,courier,monospace]In hell[/font][/center]

Link to comment
Share on other sites

toader, Be carefull with _stringbetween. The doc says

Success: A 0 based $array[0] contains the first found string.

It can return multiple rows as demonstrated by the following code
;::: #include <ARRAY.AU3>#include <STRING.AU3>$a = 'abcdefabcdabcdefghijdxyzc' $result = _StringBetween($a,'c','f') _arraydisplay($result) ConsoleWrite(_arraytostring($result) & @LF)
If multiple rows are returned they are delimited by a "|". kylomas

Edit: correction - if multiple rows are found you use arraytostring which inserts a delimiter of "|" between elements

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
Share on other sites

toader,

Be carefull with _stringbetween. The doc says

It can return multiple rows...

kylomas

Thank you, i'll fix my code, but here is another problem coz $a is real equal with $b

$aString=155
$aPages = Round($aString,-0.1) ; $aPages = 16
$b = $aPages ; is 16
$a = $a+1 ; is 1..2.3..4. up to 16
Edited by toader

[center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Don't utter a single word[/font][/center][center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Just shut your pretty mouth[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you again[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you[/font][/center][center][font=courier new,courier,monospace]In hell[/font][/center]

Link to comment
Share on other sites

You keep changing the problem you're seeing, either you can't get out of a For loop or you can't get your function to work. Because right now, the first problem has nothing whatever to do with the second problem. Not to mention, you haven't yet posted a workable script that anyone would be able to test to see what you are doing wrong to get that error message. Post a WORKING script, and not just a function that no one can run, if you would like any help.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Yes, and whatever produces this console message was not posted

kylomas

That is posted.. and i don't understand why after posting and showing that $a<>$b that continue looping.. :oops:

[center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Don't utter a single word[/font][/center][center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Just shut your pretty mouth[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you again[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you[/font][/center][center][font=courier new,courier,monospace]In hell[/font][/center]

Link to comment
Share on other sites

That is posted.. and i don't understand why after posting and showing that $a<>$b that continue looping.. :oops:

Why shouldn't it continue looping?

You don't even have a reference to ExitLoop in that code.

Are you taking the piss?

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

You don't even have a reference to ExitLoop in that code.

Where? The code in # 4 will not produce that message...regardless, if you want help you need to post a reproducer.

Post a WORKING script, and not just a function that no one can run, if you would like any help.

Sorry that i not post the reproducer... that is not legit with Term of Use, sorry i can't..

But also have good news.. i have find the problem, problem is in my pseudo looping))

If $result > $a Then
     ConsoleWrite (' I found it: '&$result& ' link: ' & $oLink.href & @CRLF)
     _Repeat()

In 1 for, is started the same for function one more time..

and more and more.. when i close last.. another continue working...

Thank all a lot!

Edited by toader

[center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Don't utter a single word[/font][/center][center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Just shut your pretty mouth[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you again[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you[/font][/center][center][font=courier new,courier,monospace]In hell[/font][/center]

Link to comment
Share on other sites

kylomas, i have change my name coz i don't like when somebody call me by name :oops:

Thank you.. you have help me to find my stupid error ))

[center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Don't utter a single word[/font][/center][center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Just shut your pretty mouth[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you again[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you[/font][/center][center][font=courier new,courier,monospace]In hell[/font][/center]

Link to comment
Share on other sites

  • Moderators

6105,

Sorry that i not post the reproducer... that is not legit with Term of Use

I am sure those who replied to you will note that and not be so helpful when you post in future. And more importantly I have also noted that you seek help for non-legitimate code. This is the second time you have come to my attention in the past few days - please make sure there is not a third. :oops:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...