Sign in to follow this  
Followers 0
Xenobiologist

Declare Huge Array With $variables

10 posts in this topic

Hi,

sounds stupid. Maybe it is. :think:

But what is the best way to create an array with let's say 50 variables in it? I think, StringSplit won't work because I want $vars in the array and no strings.

I searched a bit, but couldn't find something that helps me out.

It must be easier than

#include <Array.au3>
Dim $avArray[ ..... ]
$avArray[0] = $1
$avArray[1] = $2
$avArray[2] = $3
$avArray[3] = $4
$avArray[4] = $5
...

Thank you!

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

What about

Dim $arr[49];And variables $0 - $49...
For $i = 0 to 49
$arr[$i] = Eval(String($i))
Next

~cdkid

Edited by cdkid

AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!

Share this post


Link to post
Share on other sites

HI,

yeah I thought of that, too. But the problem is it doesn't work. :think:

$defaultstatus = "1Test"
$options = "2Test"
$restart = "3Test"
$undo = "4Test"

Dim $LabelArray = StringSplit("$defaultstatus,$options,$restart,$undo",",")
    
MsgBox(0,"",Eval(String($LabelArray[1])))

Any ideas?

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

Hmmh, I thought there is an easy solution and someone could guide me to it. :think:

Nobody?

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

Hmmh, I thought there is an easy solution and someone could guide me to it. :think:

Nobody?

So long,

Mega

I seriously don't understand what you want to do.

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

I seriously don't understand what you want to do.

Hi,

:think: okay I try to make it a bit more clear. I have got a lot of variables defined in my script. And now I want to have an array with some of them like

DIM $array = $huhu, $haha, $hoho, $hehe, $andsoOn

I can create something like that this way:

Global $buttonArray = _ArrayCreate($ones_B, $twos_B, $threes_B, $fours_B, $fives_B, $sixes_B, $threeOK_B, $fourOK_B, _
            $fullHouse_B, $shortRun_B, $longRun_B, $yahtzee_B, $chance_B)

But only 21 entries.

I can use _ArrayAdd() or soemthing like:

#include <Array.au3>
Dim $avArray[ ..... ]
$avArray[0] = $1
$avArray[1] = $2
$avArray[2] = $3
$avArray[3] = $4
$avArray[4] = $5

But there must be an easier way.

Now a bit more clear?

So long,

Mega

Edited by th.meger

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

Hi,

:think: okay I try to make it a bit more clear. I have got a lot of variables defined in my script. And now I want to have an array with some of them like

DIM $array = $huhu, $haha, $hoho, $hehe, $andsoOn

I can create something like that this way:

Global $buttonArray = _ArrayCreate($ones_B, $twos_B, $threes_B, $fours_B, $fives_B, $sixes_B, $threeOK_B, $fourOK_B, _
            $fullHouse_B, $shortRun_B, $longRun_B, $yahtzee_B, $chance_B)

But only 21 entries.

I can use _ArrayAdd() or soemthing like:

#include <Array.au3>
Dim $avArray[ ..... ]
$avArray[0] = $1
$avArray[1] = $2
$avArray[2] = $3
$avArray[3] = $4
$avArray[4] = $5

But there must be an easier way.

Now a bit more clear?

So long,

Mega

I don't think it's going to be easier, unless the before vars were in an array also.

Dim $buttonArray[14] = ['', $ones_B, $twos_B, $threes_B, $fours_B, $fives_B, $sixes_B, $threeOK_B, $fourOK_B, $fullHouse_B, $shortRun_B, $longRun_B, $yahtzee_B, $chance_B]
Could do it this way with Beta I suppose.

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

You know.. the limitations to _ArrayCreate only exist because that's what the function is coded as... If you copy out the function from the include you can make it capable of handling much more...

This example will let you create an array with 23 elements.. You just need to add "$v_## = 0" up to the number of variables you anticipate needing to be able to add. Remember that it starts with 0, so if you go

upto $v_22 then you really have 23 potential elements.

Dim $Array
$Array = _ArrayCreate ( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 )

For $x = 1 To $Array[UBound ( $Array )-1]
MsgBox ( 0, "", $Array[$x-1] )
Next



;===============================================================================
;
; Function Name:    _ArrayCreate()
; Description:    Create a small array and quickly assign values.
; Parameter(s):  $v_0  - The first element of the array.
;                  $v_1  - The second element of the array (optional).
;                  ...
;                  $v_20 - The twentyfirst element of the array (optional).
; Requirement(s):   None.
; Return Value(s):  The array with values.
; Author(s):        Dale (Klaatu) Thompson
; Note(s):        None.
;
;===============================================================================
Func _ArrayCreate($v_0, $v_1 = 0, $v_2 = 0, $v_3 = 0, $v_4 = 0, $v_5 = 0, $v_6 = 0, $v_7 = 0, $v_8 = 0, $v_9 = 0, $v_10 = 0, $v_11 = 0, $v_12 = 0, $v_13 = 0, $v_14 = 0, $v_15 = 0, $v_16 = 0, $v_17 = 0, $v_18 = 0, $v_19 = 0, $v_20 = 0, $v_21 = 0, $v_22 = 0)
    
    Local $i_UBound = @NumParams
    Local $av_Array[$i_UBound]
    Local $i_Index

    For $i_Index = 0 To ($i_UBound - 1)
        $av_Array[$i_Index] = Eval("v_" & String($i_Index))
    Next
    Return $av_Array
EndFunc  ;==>_ArrayCreate

Share this post


Link to post
Share on other sites

Further, does anyone know why no one has simply made the change to the _ArrayCreate function to allow it to create a lot more elements?

Share this post


Link to post
Share on other sites

Further, does anyone know why no one has simply made the change to the _ArrayCreate function to allow it to create a lot more elements?

Thanks! Yeah, I really wanna know that, too. :(

So long,

Mega

I don't think it's going to be easier, unless the before vars were in an array also.

CODE

Dim $buttonArray[14]= ['', $ones_B, $twos_B, $threes_B, $fours_B, $fives_B, $sixes_B, $threeOK_B, $fourOK_B, $fullHouse_B, $shortRun_B, $longRun_B, $yahtzee_B, $chance_B]

Could do it this way with Beta I suppose.

@SmOke_N : I knew there had to be something easier. :think:

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

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