Jump to content

Recommended Posts

Posted

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!

Posted

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

 

Posted

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.

Posted

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 ().

Posted

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

Posted

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

 

Posted

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

Posted (edited)

This makes it a lot simpler

For 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
EndIf

If you are done with the array long before the program ends you can free memory by

calling _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 by MilesAhead

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
×
×
  • Create New...