Sign in to follow this  
Followers 0
wuschelbeutel

Some beginner questions (arrays, basic function)

5 posts in this topic

1. Lets say you want to invoke an AutiIT function but none of the parameters are required. However, you want to use the third optional parameter. What do you pass into the first two parameters to say that you want to keep the default for them?

2. Why would you use the AutiIt function Call instead of invoking a function directly?

3. How do you blow up each element of an array by a certain constant, without having to resort to a loop and explicitly (and tediously) adding it to each element. E.g., I want to do this:

Const $q = 45

Global $xbuttomLeft[4] = [$q+2, $q+567, $q+353, $q+1029]

Share this post


Link to post
Share on other sites



For your first question, check out the Help file under Function Notes.

I just saw a discusson on your second question a couple of days ago, trying to dig up the link now.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

2. Why would you use the AutoIt function Call instead of invoking a function directly?

You could use this in the case where you are calling the function by it's named stored in a variable, or if you had several functions with the same name starting it, such as _Function 1(), _Function2(), you'd call them this way

For $i = 1 to 2
    Call("_Function" & $i)
Next
Edited by BrewManNH

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

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

3) create a UDF, so you can re-call it...that way, you don't have to do the loop each time, the script will

#include <Array.au3>
$q = 45
Dim $xbuttomLeft[4] = [2, 567, 353, 1029]
_ArrayDisplay ($xbuttomLeft)
$returnedarray = Call ( "AddToArray", $xbuttomLeft, $q )
_ArrayDisplay ($returnedarray)
Func AddToArray ($array, $integer)
If Not IsArray ( $array ) Or Not StringIsInt( $integer ) Then Return False
For $i = 0 to UBound ( $array ) - 1
  $array[$i] = $array[$i] + $integer
Next
Return $array
EndFunc
Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

Thanks everyone!

Share this post


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
Sign in to follow this  
Followers 0