Jump to content

Recommended Posts

I'm new to all of this, and I need some pointers as to what documentation would be relevant for what I'm trying to achieve.


I have a set number of variables, for simplicity let's say 3. 

My script does a set of actions, only one of the actions needs the variable. I'm looking for a way to make my script loop 3 times - so that it can perform the whole script 3 times, using each of the variables one time.

Just as an example, see below. Instead of the "Send($var1)" on line 6 - I'd like to somehow make my script loop three times - sending first $var1, then $var2 and then $var3

Is it possible? What do I need to read up on? 


#include <AutoItConstants.au3>
$var1 = 'abc'
$var2 = 'def'
$var3 = 'ghi'
MouseClick("primary", 284, 192, 1)

MouseClick("primary", 104, 438, 1) 
WinWait("Information - \\Remote")
WinActivate("Information - \\Remote")
WinWait("Information - \\Remote")
WinActivate("Information - \\Remote")



Link to post
Share on other sites
3 minutes ago, mikell said:

Hint :)

$s = ""
For $i = 1 to 3
     $s &= $i & @crlf
Msgbox(0,"", $s)


I might have misunderstood your hint completely, but I ended up putting the variables in an array and then doing a while loop with an increasing variable in it.  

I'm completely new to any form of coding, so I'm not sure if that's what you were trying to hint... It worked anyway, not sure if it's the most efficient way of doing it - but it works!

#include <Array.au3>
Local $array = ["abc", "def", "ghi"]
Local $i = 0

While $i <= 2

        $i = $i + 1


Link to post
Share on other sites
3 hours ago, zxqcz said:

I might have misunderstood your hint completely ...

@mikell just wanted to point out the functionality of a loop in general.

3 hours ago, zxqcz said:

I ended up putting the variables in an array and then doing a while loop with an increasing variable in it.

You can still use a For..Next loop, see :

#include <Array.au3>

; 0-based array :
; -------------------------------------------------------------------
Local $aArray0 = ["abc", "def", "ghi"]

ConsoleWrite("+ using a 0-based array :"  & @CRLF)

; The loop variable (here $i) will be declared by the "For"-Statement
For $i = 0 To (UBound($aArray0) - 1)
    ConsoleWrite("Counter   : " & $i & @CRLF)
    ConsoleWrite("->Element : " & $aArray0[$i] & @CRLF)
_ArrayDisplay($aArray0, "0-based")

ConsoleWrite("======================================" & @CRLF)

; 1-based array :
; -------------------------------------------------------------------
; the first value (index[0]) contains the number of elements
Local $aArray1 = [3, "abc", "def", "ghi"]

ConsoleWrite("+ using a 1-based array :"  & @CRLF)

For $i = 1 To $aArray1[0]
    ConsoleWrite("Counter   : " & $i & @CRLF)
    ConsoleWrite("->Element : " & $aArray1[$i] & @CRLF)
_ArrayDisplay($aArray1, "1-based")


EDIT :  @zxqcz


Can't find a way to edit my post...

"New Members" cannot edit their posts yet. You have to wait a bit until the status changes to "Members". This happens automatically after about 24 hours and/or 5+ posts.

Edit 2:

Group changed - "Edit" should now appear .


Edited by Melba23


"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to post
Share on other sites
2 hours ago, zxqcz said:

not sure if it's the most efficient way of doing it

You can even write it that way, without having to explicitely mention how many time your loop will cycle:

Local $array = ["abc", "def", "ghi"]

For $s In $array
    ConsoleWrite($s & @LF)


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

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

    No registered users viewing this page.

  • Create New...