Sign in to follow this  
Followers 0
aleph01

Getting InputBox data into an Array

4 posts in this topic

I'm having trouble getting inputbox data into an array. This is what I have been trying:

Local $comp

Local $compArray[$arraySize]

For $i = 0 to $arraySize -1

$compArray[$i] = InputBox ("Input HP Computer Number", "Type in the next HPOPAC computer number, using the two digit format.")

$i = $i +1

Next

MsgBox (1, "The Array", $compArray[$arraySize])

I'm using the MsgBox line to try to see if the array is correct before I go on and write the rest of the code I'll need, but on the third input (even though I've been setting $arraySize to 5 or 6), I get an error on the MsgBox line at $compArray[$arrraySize] saying that the "array varible has incorrect number of subscripts or subscript dimension range exceeded."

What I'm trying to do is write a script that will allow a user to copy a file to one or more computers on a network. I just can't seem to get the array to work out for me using an InputBox. Can anyone see what I'm doing wrong, or have a more elegant way to accomplish this?

Any help is greatly appreciated.

_aleph_


Meds.  They're not just for breakfast anymore. :'(

Share this post


Link to post
Share on other sites



Try this:

#include <Array.au3>
Local $arraySize = 5
Local $compArray[$arraySize]
For $i = 0 to $arraySize -1
    $compArray[$i] = InputBox ("Input HP Computer Number", "Type in the next HPOPAC computer number, using the two digit format.")
Next
_ArrayDisplay($compArray)

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Thanks, UEZ. I was unaware of the _ArrayDisplay command. With it, I might have been able to spot the real mistake ($i = $i +1 in a for/next loop).

I guess it's pretty easy to spot a noob. Oh well, I may not be good, but I'm getting better all the time. Thanks again, and thanks to all of the dedicated AutoIt users who provide support for those of us who are just now getting their feet wet.


Meds.  They're not just for breakfast anymore. :'(

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

May I ask you for which company you are working for?

Btw, more user friendly might be this method:

#include <Array.au3>
$comp = InputBox ("Input HP Computer Number", "Type in the next HPOPAC computer numbers separated with comma, using the two digit format." & @CRLF & @CRLF & _
                                                                                        "E.g. 23,22,12,33,10,99")
$compArray = StringSplit($comp, ",", 2)
_ArrayDisplay($compArray)

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

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