Jump to content

Recommended Posts

Posted (edited)

Hello I am new on autoit and I was writing a  bot but seems that I have a problem with my loop that counts cycles. Can you take a look and sugest anything? This is only part of the script.

Func Main()
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
            Case $Start
            Start()



         Case $Stop
               Stop()
Return Start()
    EndSwitch
 WEnd

 EndFunc

Func Start()
Global $var2 = GUICtrlRead ($Input1)
      Local $Input1 = ""

Sleep(20)

Sleep(Random(1,200))
Return Patikra0()

   EndFunc

Func Patikra0()
   Local $var1 = GUICtrlRead ($Input1)

   Local $Input1 = ""


   If $var1 = 0 and $var2 = 0 Then

      $Loop0 = 0

   ElseIf $var1 <> 0 or $var2 <> 0 Then
      $Loop0 +=1 ;~       I need this $Loop0 to add +1 and not stack overflow my funck. This variable needs to count.

   EndIf
   GUICtrlSetData ($gap0, $Loop0)

Return Patikra1()
EndFunc


Func Patikra1()
   Local $var1 = GUICtrlRead ($Input1)


   Local $Input1 = ""


   If $var1 = 1 and $var2 = 1 Then

      $Loop1 = 0 ;~       

   ElseIf $var1 <> 1 or $var2 <> 1 Then
   $Loop1 += 1 I need this $Loop1 to add +1 and not stack overflow my funck. This variable needs to count.
   EndIf
   GUICtrlSetData ($gap1, $Loop1)
Return Start()
EndFunc


Func Stop()
   Exit 0

   EndFunc


 

Edited by Melba23
Added code tags
  • Moderators
Posted

Tomm,

Welcome to the AutoIt forums.

I am not surprised that you get overflow problems with that code - it is as recursive a piece of code as I have ever seen posted here! it is also one of the more impenetrable scripts I have come across, without a word of explanation on what is happening - how a bout a description of what it is you are trying to accomplish?

M23

P.S. When you post code please use Code tags - see here how to do it.  Then you get a scrolling box and syntax colouring as you can see above now I have added the tags.

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

 

Posted

I am trying to count different variables that I put in and the gap between them. Mainly my variable $Loop count gap between sequence of numbers.

  • Moderators
Posted

Tomm,

As clear as mud. You seem only to have a single input ($Input1), so where do you get these "different variables" that you "put in"? You certainly do read that input twice and put the results in $var1 & $var2, but as you only leave a maximum of 220 msecs inbetween the 2 reads, I wonder how you ever expect the 2 to differ.....

Help us to help you  - please provide a decent explanation of what is supposed to happen in this script or we are not really going to be able to offer you any sensible help as to how to structure your code.

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

 

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
  • Recently Browsing   0 members

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