Sign in to follow this  
Followers 0
MasonMill

array index count

4 posts in this topic

hey guys,

I looked through the help file functions to no avail. Is there a way to grab the array index instead of its value?

 

Say like

$somearray[0][1]=500

$somearray[0][2]=501

$somearray[0][3]=502

$somearray[1][1]=503

$somearray[1][2]=504

$somearray[1][3]=505

 

I want to use the first array index "$somearray[0][2]" as its index and not its value, so in this case 0. Next I would use "$somearray[1][2]" as 1.  Is there a way to do this? I just dont want to create another set of variables to do this.

Thnaks in advance,

Mason

 

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

Use Enums...or I've misread what you want:

Global Enum $iArray1d_Jeff, $iArray1d_Lilly, $iArray1d_UBound
Global Enum $iArray2d_Age, $iArray2d_Sex, $iArray2d_UBound
Global $aUsers[$iArray1d_UBound][$iArray2d_UBound]
$aUsers[$iArray1d_Jeff][$iArray2d_Age]=20
$aUsers[$iArray1d_Jeff][$iArray2d_Sex]="M"
$aUsers[$iArray1d_Lilly][$iArray2d_Age]=25
$aUsers[$iArray1d_Lilly][$iArray2d_Sex]="F"

ConsoleWrite("Jeff is Aged=[" & $aUsers[$iArray1d_Jeff][$iArray2d_Age] & "]." & @CRLF)
Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

Nice jdelaney. Finally someone gets it!


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

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

  • Similar Content

    • SkysLastChance
      By SkysLastChance
      I keep losing the count of my $r varable when I go into the dropdown () function and call the same function.
      #include <Excel.au3> #include <AutoItConstants.au3> #include<GUIConstantsEx.au3> #include<EditConstants.au3> #include<GUIConstants.au3> Global $iBox, $oExcel, $oWorkbook, $r = 1, $x = 3 HowMany() Excel () Dropdown () Sleep (500) Func Dropdown () $list = GUICreate("Chart", 225, 80) $combobox = GUICtrlCreateCombo("Clinic 1", 10, 10, 120, 20) GUICtrlSetData(-1, "Clinic 2|Clinic 3|Clinic 4") $button = GUICtrlCreateButton("Select", 10, 40, 60, 20) GUISetState(@SW_SHOW) While 1 $guibox = GUIGetMsg() Select Case $guibox = $button Select Case GUICtrlRead($combobox) = "Clinic 1" GUIDelete($list) Auto () EndSelect Case $guibox = $GUI_EVENT_CLOSE EndSelect WEnd EndFunc Func HowMany() Local $iMsg While 1 ;~ Turn input into a number $iBox = Number(InputBox ("Regestration", "How Many Patients are there total?")) ;~ If user enters a string or cancels then get them to try again If $iBox = 0 Then $iMsg = MsgBox(1,'Regestration', 'Please enter a valid number') If $iMsg = 2 Then Exit Else ExitLoop EndIf WEnd EndFunc Func Excel() While ProcessExists("EXCEL.EXE") $ms = MsgBox(5,"","Process error. You have an Excel sheet open. You must close it in order to let this program work. Please close it now.") If $ms=2 Then Exit ;~ Doesn't require sleep since the script is paused by the MsgBox above ;~ Sleep(250) WEnd ;~ Shouldn't use Global Scope inside functions moved to top of script Local $sExcelFile = FileOpenDialog("Choose/Create Excel File", @ScriptDir, "(*.xlsx)") If FileExists($sExcelFile) Then ;~ Shouldn't use Global Scope inside functions moved to top of script $oExcel = _Excel_Open () $oWorkbook = _Excel_BookOpen($oExcel,$sExcelFile) ;this will open the chosen xls file. Else $oExcel = _Excel_Open() $oWorkbook = _Excel_BookNew($oExcel, 2);this is here to create the xls file if it does not exist. EndIf EndFunc Func Auto() Local $aArray1 = _Excel_RangeRead($oWorkbook) ;~ If $iBox is greater than no. of rows in $aArray then $iBox equals the number of rows in $aArray If $iBox > (UBound($aArray1) - 1) Then $iBox = UBound($aArray1) - 1 For $i = 2 To UBound($aArray1) - 1 ;$i =0 Start from row A If $aArray1[$i][1] = "" Then Continueloop $sR0 = $aArray1[$i][0] ;status $sR1 = $aArray1[$i][1] ;Last Name $sR2 = $aArray1[$i][2] ;First Name $sR3 = $aArray1[$i][3] ;DOB $sR4 = $aArray1[$i][4] ;Sex $sR5 = $aArray1[$i][5] ;Mailling Address $sR6 = $aArray1[$i][6] ;Zip $sR7 = $aArray1[$i][7] ;Phone # $sR8 = $aArray1[$i][8] ;Visit Reason $sR9 = $aArray1[$i][9] ;Insurance $sR10 = $aArray1[$i][10] ;Clinic $sR11 = $aArray1[$i][11] ;Provider $sR12 = $aArray1[$i][12] ;Appt Time $sR13 = $aArray1[$i][13] ;Appt Date WinWaitActive ("Untitled - Notepad") ControlSend("Untitled - Notepad", "", "", $sR1 & ',' & $sR2 & @CR) $r += 1 If $r > $iBox Then Exit Dropdown () Next EndFunc so the second time I choose clinic 1 I want it to go to the next row which would be Champ brett in my example excel.
       
      Test.xlsx
      Example Format.xlsx
    • 31290
      By 31290
      Hi guys, 
      I'd like to write a piece of tool that would allow me to update a certain field in our Active Directory from a comma separated csv file composed like this:

      This file, automatically generated, can hold more than 10k lines.
      Thus, I need column A to be in one variable, column B in a second one and column C in a third one.
      I'm really missing this part as updating the AD is fairly easy once the 3 variable are populated. 
      I see things like this:
      Here's my attempts at the moment:
      #include <File.au3> #include <Array.au3> Global $csv_file = @DesktopDir & "\Book1.csv" Global $aRecords If Not _FileReadToArray($csv_file,$aRecords) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf For $x = 1 to $aRecords[0] Msgbox(0,'Record:' & $x, $aRecords[$x]) ; Shows the line that was read from file $csv_line_values = StringSplit($aRecords[$x], ",",1) ; Splits the line into 2 or more variables and puts them in an array ; _ArrayDisplay($csv_line_values) ; Shows what's in the array you just created. ; $csv_line_values[0] holds the number of elements in array ; $csv_line_values[1] holds the value ; $csv_line_values[2] holds the value ; etc Msgbox(0, 0, $csv_line_values[1]) Next Any help on this please? 
      Thanks in advance
      -31290-
    • StMaSi
      By StMaSi
      So, I have a text file like this...
      "Label", {left}, {top}, {width}, {height} "Label", {left}, {top}, {width}, {height} "Label", {left}, {top}, {width}, {height} "Label", {left}, {top}, {width}, {height} "Label", {left}, {top}, {width}, {height} What I'm attempting to do is read the data from this file, into an array, and use it to create checkboxes on a form like this...
      For $cb = 0 to 4 ; line numbers $Checkbox[$cb] = GUICtrlCreateCheckbox({label}, {left}, {top}, {width}, {height}) Next However, I can't figure out how to read the file into the array so as to be able to assign the data elements appropriately. I'm obviously missing something (or more than likely more than one something), but can't figure it out.
      Can anyone assist with this?
      Thanx.
       
    • dexto
      By dexto
      Why idea why would I get an error (Autoit Beta 3.3.15.0):
      Local $json[] Local $map[] $map['test'] = 'hello' Local $array[5] = [1, 2, 3, 4, 5] $json["data"] = $map $json["data"]["arr"] = $array ConsoleWrite($json["data"]["arr"][0] & @CRLF)  
    • cookiemonster
      By cookiemonster
      Im trying to read a JSON file into an array.
       
      The JSON looks like this:
       
      { "project_info": { "project_number": "123456789", "url": "https://www.website.com", "project_id": "PRJ08", "Bucket": "Buk09" }, "client": [ { "client_info": { "id": "1:1001306455", "info": { "name": "banana" } }, "oauth_client": [ { "client_id": "1001306455694-m3h6v", "client_type": 3 } ], "a_key": [ { "key": "dkldkdkd" } ], "Avail": { "ana": { "status": 1 }, "vit": { "status": 1, "other": [] }, "ad": { "status": 2 } } }, { "client_info": { "id": "1:1838346", "info": { "name": "orange" } }, "oauth_client": [ { "client_id": "2145696315633-dmdhe", "client_type": 3 } ], "a_key": [ { "key": "osikdme" } ], "Avail": { "ana": { "status": 1 }, "vit": { "status": 1, "other": [] }, "ad": { "status": 2 } } }, ], "configuration_version": "1" } What I want to do is read it all into one single large array, can anyone help? 
      All I have so far is:
      #include "JSON.au3" #include "array.au3" $file = fileread("C:\file.json") JsonToArray($file) Func JsonToArray($JSON) $JSON = StringRegExpReplace($JSON, "[\[\]{}]", "") $sBreak = StringSplit($JSON, ",") For $a = 1 To $sBreak[0] $t = _JSONDecode("{" & $sBreak[$a] & "}") _ArrayDisplay($t, "multi " & $a & " of " & $sBreak[0]) Next EndFunc ;==>JsonToArray