Jump to content

Assigning data to array element defined by a variable


micechal
 Share

Recommended Posts

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?

Link to comment
Share on other sites

  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...