Jump to content

Some beginner questions (arrays, basic function)

Recommended Posts

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]

Link to post
Share on other sites
  • Moderators

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.

"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 post
Share on other sites

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

Link to post
Share on other sites

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
Return $array
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.
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...