Nippon71

Naming Array Variable after Data in another Array

6 posts in this topic

Hello Autoit forum, 

i created script that runs through text files and finds out how many arrays i need to create for the data in the files.

I would like to create the appropriate Array automatically depending on the data saved in a previous run through.

For expample Array1 (first run through) [5] = ["Car","bike",Tree","Train","Shoe"]

I would like him to create an array $aCars but i dont know that "Car" will be in my first array so i cant write it manually. 

At the core i really only need the ability to create multiple Arrays with some kind of automated self naming system.

 

Thanks a lot 
Nippon71

Share this post


Link to post
Share on other sites



I think you are looking for something like "Maps" functionality. I think it's still only in beta with AutoIt, currently.

Alternatively you could use "Scripting.Dictionary" here's an example:

$oDictionary = ObjCreate("Scripting.Dictionary")

;method 01
$oArray = ObjCreate("System.Collections.ArrayList");dynamic array
$oArray.Add('a')
$oArray.Add('b')
$oArray.Add('c')
$oDictionary.Add("Cars", $oArray)
ConsoleWrite( $oDictionary.Item("Cars").Count & @CRLF )
For $i=0 To $oDictionary.Item("Cars").Count-1
    ConsoleWrite( $oDictionary.Item("Cars").Item($i) & @CRLF )
Next

ConsoleWrite(@CRLF)

;method 02
Local $aArray[] = ['a','b','c'];static array
$oDictionary.Item("Cars") = $aArray
ConsoleWrite( UBound($oDictionary.Item("Cars"), 1) & @CRLF )
For $i=0 To UBound($oDictionary.Item("Cars"), 1)-1
    ConsoleWrite( $oDictionary.Item("Cars")[$i] & @CRLF )
Next

 

Share this post


Link to post
Share on other sites

The name of a variable in a program is utterly unimportant!


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

still have to put stuff in the var you set, thats not automatic

local $aList = ["car" , "bike" , "plane"]

assign("a" & $aList[0] , stringsplit("passat , acura , honda" , "," , 2))

msgbox(0, '' , eval("acar")[0] & @LF & eval("acar")[1] & @LF & eval("acar")[2])

 

 

 

Edited by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

Yes we can, but this is a terrible way of coding simple things.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

sure but even the last place finisher is 1st if he is the only one playing.


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

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