Sign in to follow this  
Followers 0
micechal

Assigning data to array element defined by a variable

4 posts in this topic

Hi. I tried searching, but found nothing, so there is my problem:

I'm trying to make a program, which will press hotkeys in user's defined intervals. The hotkey's quantity is represented by a variable which is assigned from InputBox. The problem is, that I can't change a value in array's element. This is the code:

#include <array.au3>
$ilosc = InputBox("Ilość scen","Podaj ilość scen, pomiędzy którymi chcesz się przełączać")
Global $arr[$ilosc]
$interwal = InputBox("Interwał czasowy","Podaj w sekundach odstęp czasowy między kolejnymi przełączeniami")
For $i=0 To $ilosc
Global $arr[$i] = InputBox("Skrót " & $i,"Dawaj")
Next

And the error:

Global $arr[$i] = InputBox("Skrót " & $i,"Dawaj")
Global $arr[^ ERROR

What am I doing wrong?

Share this post


Link to post
Share on other sites



try:

$ilosc = InputBox("Ilosc scen", "Podaj ilosc scen, pomiedzy którymi chcesz sie przelaczac")
Global $arr[$ilosc]
$interwal = InputBox("Interwal czasowy", "Podaj w sekundach odstep czasowy miedzy kolejnymi przelaczeniami")
For $i = 0 To $ilosc -1
    $arr[$i] = InputBox("Skrót " & $i, "Dawaj")
Next

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Thanks, now it works. The problem was

Global
? What does it do?

Share this post


Link to post
Share on other sites

Global defines the whole Array as you already had done in the second line so you should not try to redefine it when setting a single entry in the array.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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