vkrisz81 Posted November 2, 2012 Posted November 2, 2012 Hello! here is an example: 1 if $lineparts[1]="logfile" or $lineparts[1]="1stnames" or $lineparts[1]="2ndnames" or $lineparts[1]="mailservers" or $lineparts[1]="fullnames" Then 2 $filelist[$lineparts[1]]["name"]=$lineparts[2] 3 $filelist[$lineparts[1]]["object"]=f($lineparts[2],$lineparts[3]) 4 ConsoleWrite($filelist[$lineparts[1]]["name"]&@LF) 5 ConsoleWrite($lineparts[2]&@LF) 6 EndIf so, the program found the text "logfile" the 4 row write out me 2 instead of logfile.txt, but the next row looks the string, writeout logfile.txt i wanna know, why cant put into ["name"] index this text?? why??????? i can directly use text indexed array items. now why doesnt work it? thank you!
water Posted November 2, 2012 Posted November 2, 2012 You can't access an array element by name, only by index.What you are looking for are "associative arrays". Search the forum for this term and you will find a lot of examples (). My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
vkrisz81 Posted November 2, 2012 Author Posted November 2, 2012 I FOUND THAT AFTER row 2 the text indexed arra item has the text, but after row 3 that value sets to number.. is it normal?? i dont think so.
vkrisz81 Posted November 2, 2012 Author Posted November 2, 2012 i can use the formula, $arraynam['indexname'] it add me back correct value, like after row2 with an inserted consolewrite. it writes out the correct value, after f function it changes. You can't access an array element by name, only by index. What you are looking for are "associative arrays". Search the forum for this term and you will find a lot of examples ().
vkrisz81 Posted November 2, 2012 Author Posted November 2, 2012 ok now i can see, i can set 1 text called item, but after i get another text called item, last has been rewriten i sry that this is not work standardly, the other way too complicated instead of $arrayname["index1"]["item2"] thanks
vkrisz81 Posted November 2, 2012 Author Posted November 2, 2012 how can i make subarray to associated array?
water Posted November 2, 2012 Posted November 2, 2012 Did you have a look at the link I specified in post #2? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
vkrisz81 Posted November 4, 2012 Author Posted November 4, 2012 yes, i saw that but i choose another way, i use number indexed array, i think that is too complicate to use! elegant, but complicated for me in use. i will use it later! thanks
MilesAhead Posted November 4, 2012 Posted November 4, 2012 (edited) This makes it a lot simplerFor the most common case where you want case insensitive keys just call$myAssocArray = _AssocArray() ; then test succeeded by $myAssocArray <> 0 If $mAssocArray then ; do stuff with the array EndIfIf you are done with the array long before the program ends you can free memory bycalling _AssocArrayDestroy($myAssocArray)For some reason editing this post I cannot leave an underlined link named Dictionary Object. But if I could, it would be here:msdn.microsoft.com/en-us/library/x4k5wbx4(v=vs.84).aspx Edited November 4, 2012 by MilesAhead My Freeware Page
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now