Jump to content

(solved)Check my code


Recommended Posts

Just need some advices for future. In my code is big mess... When I try to make something I get error. In this one I have error too.

While 1
_IELinkClickByText($oIE, "text") ;every this click page refreshes
Sleep(1000)
$body = _IEBodyReadHTML($oIE)
If StringInStr($body, "Text") Then
  _IELinkClickByText($oIE, "link text")
ElseIf StringInStr($body, "other text") Then
  _IELinkClickByIndex($oIE, 3)                                      ;I want to add StringInStr even more...
ElseIf StringInStr($body, "text 2") Then
  _IENavigate($oIE, "link")
  ;------------------
  $i = 0
  Do
   $oTags = _IETagNameGetCollection($oIE, 'input')
   If Not @error Then
    For $oTag In $oTags
     If $oTag.type == 'submit' And $oTag.value == 'valuei' Then
      _IEAction($oTag, 'click')
      _IELoadWait($oIE)
      If Not @error Then ExitLoop
     EndIf
    Next
   EndIf
   $i = $i + 1
  Until $i = 30
  ;--------------------------------------
EndIf
Next              ; too much something here. When I remove, I get error...
EndIf
WEnd
Edited by Edgaras
Link to comment
Share on other sites

  • Moderators

sirfearless,

When I try to make something I get error

And so do the rest of us - all the time! ;)

I suggest you download SciTE4AutoIt3 from here and install it. You then get lots of extra utilities to help you code more efficiently in AutoIt. One of these is Tidy which nicely formats your code and, among other things, lets you know if you have missing loop elements. When I run your code above through Tidy I get this:

While 1
    _IELinkClickByText($oIE, "text") ;every this click page refreshes
    Sleep(1000)
    $body = _IEBodyReadHTML($oIE)
    If StringInStr($body, "Text") Then
        _IELinkClickByText($oIE, "link text")
    ElseIf StringInStr($body, "other text") Then
        _IELinkClickByIndex($oIE, 3) ;I want to add StringInStr even more...
    ElseIf StringInStr($body, "text 2") Then
        _IENavigate($oIE, "link")
        ;------------------
        $i = 0
        Do
            $oTags = _IETagNameGetCollection($oIE, 'input')
            If Not @error Then
                For $oTag In $oTags
                    If $oTag.type == 'submit' And $oTag.value == 'valuei' Then
                        _IEAction($oTag, 'click')
                        _IELoadWait($oIE)
                        If Not @error Then ExitLoop
                    EndIf
                Next
            EndIf
            $i = $i + 1
        Until $i = 30
        ;--------------------------------------
    EndIf
;### Tidy Error -> "next" is closing previous "while" on line 1
Next ; too much something here. When I remove, I get error...
;### Tidy Error: next line creates a negative tablevel.
;### Tidy Error: next line creates a negative tablevel for the line after it.
EndIf
;### Tidy Error: next line creates a negative tablevel.
;### Tidy Error: next line creates a negative tablevel for the line after it.
WEnd

So you can see at once that you have a Next and and EndIf too many. :)

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

Woooo.... I have SciTE4AutoIt3 already. Used tidy but got other errors lol... Anyway I will find my solution somehow... Going to spend few hrs on reading examples. I just need few advices how I can make my script better. Maybe I should learn functions?

Edited by sirfearless
Link to comment
Share on other sites

  • Moderators

sirfearless,

Maybe I should learn functions?

That would be an excellent idea. Have you read the excellent AutoIt tutorials that you will find here and here? They will help you a lot. :)

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

@sirfearless - when I became aware of AutoIt several years ago, one of the first things I did was read the Help file. You should browse thru it at least; come to be familiar with the AutoIt native functions and what they do, know what AutoIt can do. Then read thru the Help file again. Don't forget about the tutorials M23 has mentioned. Good luck with your projects. :)

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Link to comment
Share on other sites

  • 3 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...