Jump to content

Recommended Posts

Posted

You have 4 "values" in a For statement. The variable to store the current value of the counter, the start value, the end value and - optional - the step size.

I assume you want to use $Variable1 as the start value. So you should use:

For $Count = $Variable1 to 100

My UDFs and Tutorials:

  Reveal hidden contents

 

  • Moderators
Posted

GordonFreeman,

You need the full syntax: :)

For <variable> = <start> To <stop> [Step <stepval>]

All you would save with your suggestion is 3 spaces and a start value - given AutoIt's size when compiled is that so much extra? And in many cases you would not want $Variable1 to increase in value as the loop progresses. ;)

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:

  Reveal hidden contents

 

Posted (edited)

$Variable1 = "Hi"

$Variable2 = "My Name is..."

$Variable3 = "Gordon"

For $Count = $Variable1 to 3

msgbox( 0, "", $Count)

Next

I want make it. Sorry if I did something wrong or explained. My natural language is not English.

But return numbers. Help mee

Edited by GordonFreeman
  • Moderators
Posted (edited)

Gordon, for that you would need to create an array:

Local $var[3]
   $var[0] = "Hi"
   $var[1] = "My Name is..."
   $var[2] = "Gordon"

   For $element in $var
       msgbox(0, "", $element)
   Next
Edited by JLogan3o13

"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!

  • Moderators
Posted (edited)

GordonFreeman,

To do that you need an array. :)

Global $aVariable[3] = ["Hi", "My Name is...", "Gordon"]

For $i = 0 To 2
    MsgBox( 0, "", $aVariable[$i])
Next

I suggest reading the Arrays tutorial in the Wiki if you are not very used to using them. ;)

  Quote

Sorry if I did something wrong or explained. My natural language is not English

You did nothing wrong. ;)

M23

JLogan3o13,

Your turn! :)

Edited by Melba23

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:

  Reveal hidden contents

 

Posted

If he could to use variables and use Execute.

$Variable1 = "Hi"
$Variable2 = "My Name is..."
$Variable3 = "Gordon"
For $Count = 1 to 3
MsgBox( 0, "", Execute("$Variable" & $Count))
Next

Adam

Posted

Ok. but now I have another doubt.

What if I want to store values

$Variable[5]
For $i = 0 to 4
    $Variable[$i] = IniRead( "TEST.INI", "Test", "TestSec" & $i, "Error")
Next

i try it but not work. my script close.

work will that way:

$Variable1 = IniRead( "TEST.INI", "Test", "TestSec1, "Error")
$Variable2 = IniRead( "TEST.INI", "Test", "TestSec2, "Error")
$Variable3 = IniRead( "TEST.INI", "Test", "TestSec3, "Error")
$Variable4 = IniRead( "TEST.INI", "Test", "TestSec4, "Error")
$Variable5 = IniRead( "TEST.INI", "Test", "TestSec5, "Error")

However shorter

I think I can see the error but I'm traveling here to find out how fix

Posted

Change the line to this:

$Variable[$i] = IniRead( "TEST.INI", "Test", "TestSec" & $i + 1, "Error")

Untested, but you don't have a TestSec0 so this at least aligns your ini file with your code.

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!

  Reveal hidden contents

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

Posted (edited)

  On 2/18/2012 at 2:34 AM, 'BrewManNH said:

Change the line to this:

$Variable[$i] = IniRead( "TEST.INI", "Test", "TestSec" & $i + 1, "Error")

Untested, but you don't have a TestSec0 so this at least aligns your ini file with your code.

really, i forgot

but he not returned to value of others. Just blank values

Edited by GordonFreeman
Posted

Why not use IniReadSection? But this code (as suggested by BrewManNH) works for me.

#include <Array.au3>

Local $aArray[5]
For $i = 0 to 4
    $aArray[$i] = IniRead(@ScriptDir & "TEST.ini", "Test", "TestSec" & $i + 1, "Error")
Next
_ArrayDisplay($aArray)

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

Wow, what a dramatic decrease.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

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
×
×
  • Create New...