Jump to content

how to fix my problem with (for loop)


jo0oker
 Share

Recommended Posts

Hello,

i have many function in my script call (User) and i tried many times to make them working with (for) loop ,

but every time get error (Variable used without being declared) ,

now i need any  solutions to complete the script please.

there is image for script and error

my code 

Global $array[6]
$array[0] = USER1()
$array[1] = USER2()
$array[2] = USER3()
$array[3] = USER4()
$array[4] = USER5()
$array[5] = USER6()
   Func Start()
       ToolTip("start",0,0)
       WinActivate("My_window")
       For $i = 0 To 5 Step +1
          
       Next
    EndFunc
    Func USER1()
       ToolTip("USER1",0,0)
       Local $pos = MouseGetPos()
       MouseClick("left",1443, 88,1,10)
       MouseMove($pos [0],$pos [1],10)
       Sleep(2000)
       MouseClick("left",1440, 902,1,10)
       MouseMove($pos [0],$pos [1],10)
       Sleep(2000)
       MouseClick("left",1866, 199,1,10)
       MouseMove($pos [0],$pos [1],10)
       Sleep(2000)
    EndFunc

    Func USER2()
       ToolTip("USER1",0,0)
       Local $pos = MouseGetPos()
       MouseClick("left",1443, 88,1,10)
       MouseMove($pos [0],$pos [1],10)
       Sleep(2000)
       MouseClick("left",1440, 902,1,10)
       MouseMove($pos [0],$pos [1],10)
       Sleep(2000)
       MouseClick("left",1866, 199,1,10)
       MouseMove($pos [0],$pos [1],10)
       Sleep(2000)
    EndFunc

 

2017-10-28_112651.png

Link to comment
Share on other sites

its called by HotKeySet

 

Global $Paused

HotKeySet("{F1}", "Start")
HotKeySet("{F2}", "Pause")
HotKeySet("{F3}", "Close")
HotKeySet("{F4}", "map")

_Startup()

Func _Startup()
   While 1
    ToolTip("Startup",0,40)
    Sleep(100)
    WEnd
   EndFunc

Func Close()
   Exit
EndFunc

Func Pause()
   ToolTip("Pause",0,0)
   $Paused = NOT $Paused
    While $Paused
       sleep(100)
      WEnd
   EndFunc

Func Moswll()
   Send("{CTRLDOWN}")
    MouseWheel("down",6)
    Send("{CTRLUP}")
    Sleep(2000)
EndFunc

Global $array[6]
$array[0] = USER1()
$array[1] = USER2()
$array[2] = USER3()
$array[3] = USER4()
$array[4] = USER5()
$array[5] = USER6()

   Func Start()
       ToolTip("start",0,0)
       WinActivate("jo0oker")
       For $i = 0 To 5 Step +1


       Next
    EndFunc

 

Link to comment
Share on other sites

  • Developers

That means that it will  never reach the part where the Array is defined so change that to:

Global $Paused
Global $array[6]
$array[0] = USER1()
$array[1] = USER2()
$array[2] = USER3()
$array[3] = USER4()
$array[4] = USER5()
$array[5] = USER6()

HotKeySet("{F1}", "Start")
HotKeySet("{F2}", "Pause")
HotKeySet("{F3}", "Close")
HotKeySet("{F4}", "map")

_Startup()

Func _Startup()
   While 1
    ToolTip("Startup",0,40)
    Sleep(100)
    WEnd
   EndFunc

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

no idea what you are trying to tell us here, but you will have to define the array before you can use it.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

Again, I have no idea what you are trying to do with this script so only helped with why you had the error.

You will have to be much more explicit on this issue you have now before anyone can assist you further.

Jos
 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

What is the purpose of the array?  I guessing the array is to hold the names of the functions so you can run them elsewhere using Execute($array[4]) or something like that?  As it is now, when you instantiate that array you are running the functions and assigning whatever they return to the array elements, which is nothing in this case.  You might want to put them in there as strings... like $array[2]="functionname"

hth

Link to comment
Share on other sites

  • Developers
16 minutes ago, Sleepyguy said:

I am likely way over my head in this but declaring the array you need to addLocal

$i = 0 

Why do you feel this is needed? The $i in the For...Next in implicitly declaredas stated in the Helpfile:

Quote

Remarks

The variable will be created automatically with Local scope, even when MustDeclareVars is on.

Jos

 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Moderators

@Sleepyguy the OP declares $i as the counter in his For loop in the Start() function, all that is needed

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

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...