Jump to content

Search the Community

Showing results for tags 'assign'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • Forum FAQ
  • AutoIt

Calendars

  • Community Calendar

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 9 results

  1. My solution is to write nested arrays without copying. The problem was described hier. Function: #include <Array.au3> ; #FUNCTION# ==================================================================================================================== ; Name ..........: _ArrayNestedSet ; Description ...: Assigns a value to an element of a nested 1D array. ; Syntax ........: _ArrayNestedSet(ByRef $aArray, $vIndex, $vValue) ; Parameters ....: $aArray - an array of arrays. ; $vIndex - an index or 1d-array of indexes; ; a size if $vValue not defined (zero to delete). ; $vValue - a value (create, resize or delete if not defined). ; ; Return values .: on success - 1 ; @extended - nesting level of operation ; on failure - 0 ; @extended - nesting level of error ; @error = 1 - invalid array ; @error = 2 - invalid index ; Author ........: ; Modified ......: kovlad ; Remarks .......: ; Related .......: ; Link ..........: https://www.autoitscript.com/forum/topic/185638-assign-a-value-to-an-array-in-array-element/ ; https://www.autoitscript.com/trac/autoit/ticket/3515?replyto=description ; Example .......: Yes ; =============================================================================================================================== Func _ArrayNestedSet(ByRef $aArray, $vIndex, $vValue = Default) Local $extended = @extended + 1 If IsArray($vIndex) Then If UBound($vIndex, 0) <> 1 Then _ Return SetError(2, $extended) If UBound($vIndex) > 1 Then If UBound($aArray, 0) <> 1 Then _ Return SetError(1, $extended) ; keep index for this array Local $i = $vIndex[0] If $i < 0 Or UBound($aArray) <= $i Then _ Return SetError(2, $extended) ; delete index of this array _ArrayDelete($vIndex, 0) ; recursive function call Local $return = _ArrayNestedSet($aArray[$i], $vIndex, $vValue) If @error Then Return SetError(@error, @extended + 1, 0) Else Return SetExtended(@extended + 1, 1) EndIf Else $vIndex = $vIndex[0] EndIf EndIf If $vValue = Default Then If $vIndex < 0 Then _ Return SetError(2, $extended) If $vIndex = 0 Then ; delete array and free memory $aArray = 0 Return SetExtended($extended, 1) EndIf If UBound($aArray, 0) = 1 Then ; resize array keeping data ReDim $aArray[$vIndex] Return SetExtended($extended, 1) Else ; create new nested array Local $aTmp[$vIndex] $aArray = $aTmp Return SetExtended($extended, 1) EndIf Else If UBound($aArray) <= $vIndex Then _ Return SetError(2, $extended + 1) ; set value of array entry $aArray[$vIndex] = $vValue Return SetExtended($extended, 1) EndIf EndFunc Examples: ; write value to 1st nested array ConsoleWrite("@@ Debug(" & @ScriptLineNumber & ") : write value to 1st nested array" & @CRLF) Local $aTmp1[4] = [1,2,3,4] _ArrayDisplay($aTmp1, "$aTmp1") Local $aArray[2] = [$aTmp1] ConsoleWrite( _ "_ArrayNestedSet($aArray[0], 3, 14) = " & _ArrayNestedSet($aArray[0], 3, 14) & @CRLF & _ " @error = " & @error & @CRLF & _ " @extended = " & @extended & @CRLF & @CRLF) _ArrayDisplay($aArray[0], "$aArray[0]") ; resize 1st nested array ConsoleWrite("@@ Debug(" & @ScriptLineNumber & ") : resize 1st nested array" & @CRLF) ConsoleWrite( _ "_ArrayNestedSet($aArray[0], 8) = " & _ArrayNestedSet($aArray[0], 8) & @CRLF & _ " @error = " & @error & @CRLF & _ " @extended = " & @extended & @CRLF & @CRLF) _ArrayDisplay($aArray[0], "$aArray[0]") ; write array to 1st nested array ConsoleWrite("@@ Debug(" & @ScriptLineNumber & ") : write array to 1st nested array" & @CRLF) Local $aTmp11[4] = [11,12,13,14] _ArrayDisplay($aTmp11, "$aTmp11") ConsoleWrite( _ "_ArrayNestedSet($aArray[0], 2, $aTmp11) = " & _ArrayNestedSet($aArray[0], 2, $aTmp11) & @CRLF & _ " @error = " & @error & @CRLF & _ " @extended = " & @extended & @CRLF & @CRLF) _ArrayDisplay(($aArray[0])[2], "($aArray[0])[2]") ; write value to 2nd nested array using index array ConsoleWrite("@@ Debug(" & @ScriptLineNumber & ") : write value to 2nd nested array using index array" & @CRLF) Local $aIndex1[2] = [2,3] _ArrayDisplay($aIndex1, "$aIndex1") ConsoleWrite( _ "_ArrayNestedSet($aArray[0], $aIndex1, 140) = " & _ArrayNestedSet($aArray[0], $aIndex1, 140) & @CRLF & _ " @error = " & @error & @CRLF & _ " @extended = " & @extended & @CRLF & @CRLF) _ArrayDisplay(($aArray[0])[2], "($aArray[0])[2]") ; resize 2nd nested array ConsoleWrite("@@ Debug(" & @ScriptLineNumber & ") : resize 2nd nested array" & @CRLF) Local $aIndex1[2] = [2,8] _ArrayDisplay($aIndex1, "$aIndex1") ConsoleWrite( _ "_ArrayNestedSet($aArray[0], $aIndex1) = " & _ArrayNestedSet($aArray[0], $aIndex1) & @CRLF & _ " @error = " & @error & @CRLF & _ " @extended = " & @extended & @CRLF & @CRLF) _ArrayDisplay(($aArray[0])[2], "($aArray[0])[2]") ; create new 3rd nested array ConsoleWrite("@@ Debug(" & @ScriptLineNumber & ") : create new 3rd nested array" & @CRLF) Local $aIndex2[3] = [2,7,6] _ArrayDisplay($aIndex2, "$aIndex2") ConsoleWrite( _ "_ArrayNestedSet($aArray[0], $aIndex2) = " & _ArrayNestedSet($aArray[0], $aIndex2) & @CRLF & _ " @error = " & @error & @CRLF & _ " @extended = " & @extended & @CRLF & @CRLF) _ArrayDisplay((($aArray[0])[2])[7], ")($aArray[0])[2])[7]") ; delete 3rd nested array ConsoleWrite("@@ Debug(" & @ScriptLineNumber & ") : delete 3rd nested array" & @CRLF) Local $aIndex3[3] = [2,7,0] _ArrayDisplay($aIndex3, "$aIndex2") ConsoleWrite( _ "_ArrayNestedSet($aArray[0], $aIndex3) = " & _ArrayNestedSet($aArray[0], $aIndex3) & @CRLF & _ " @error = " & @error & @CRLF & _ " @extended = " & @extended & @CRLF) ConsoleWrite("IsArray((($aArray[0])[2])[7]) = " & IsArray((($aArray[0])[2])[7]) & @CRLF & @CRLF) ; write 0 in 1st nested array to delete the 2nd nested array ConsoleWrite("@@ Debug(" & @ScriptLineNumber & ") : write 0 in 1st nested array to delete the 2nd nested array" & @CRLF) Local $aIndex4[1] = [2] _ArrayDisplay($aIndex4, "$aIndex4") ConsoleWrite( _ "_ArrayNestedSet($aArray[0], $aIndex4, 0) = " & _ArrayNestedSet($aArray[0], $aIndex4, 0) & @CRLF & _ " @error = " & @error & @CRLF & _ " @extended = " & @extended & @CRLF) ConsoleWrite("IsArray(($aArray[0])[2]) = " & IsArray(($aArray[0])[2]) & @CRLF & @CRLF) ; delete 1st nested array (same as '$aArray[0] = 0') ConsoleWrite("@@ Debug(" & @ScriptLineNumber & ") : delete 1st nested array (same as '$aArray[0] = 0')" & @CRLF) Local $aIndex5[1] = [0] _ArrayDisplay($aIndex5, "$aIndex5") ConsoleWrite( _ "_ArrayNestedSet($aArray[0], $aIndex5) = " & _ArrayNestedSet($aArray[0], $aIndex5) & @CRLF & _ " @error = " & @error & @CRLF & _ " @extended = " & @extended & @CRLF) ConsoleWrite("IsArray($aArray[0]) = " & IsArray($aArray[0]) & @CRLF & @CRLF)
  2. Hello, I'd like to be able to create variables 'on the fly' by reading in some data from an SQLite database. Using this data i'd like to create variables. The data would be separated by colons (":")...'colon delimited'. I would perform a 'StringSplit' on the data to create arrays holding each colon separated value. Ideally I could then use these strings to create variables from them...possible? I know it cannot be done just piecing a string together such as "var = "$_" & 'some string'"... I think it might work using the 'Assign' command...and there is an 'Opt' option to 'ExpandVarStrings' which seems to indicate it is possible to include a "$" within a string...however the documentation is a bit spotty on that. Can anybody confirm that these might be the best practices to create variables dynamically? ...Perhaps there is another method I'm not thinking of...? I thank you in advance. Regards.
  3. Hello, i'm trying to rename a variable to another variable name (not the value attached to the variable). This would save me TONS of coding. Here is an example: <autoit> Local $clear1="$SATJ" ;sets the $clear1 variable to become $SATJ GUICtrlSetState($clear1 & "3", $GUI_UNCHECKED) ;i want this to come out to be $SATJ3, it should look something like - GUICtrlSetState($SATJ3, $GUI_UNCHECKED) </autoit> Is this possible? I've been searching all the forums and help files for hours. My javascript friend referenced me to the solution on JS, which lead me to searching through the "assign" help on autoit, but not much info on it. I've already tried <autoit> Assign($clear1, $SATJ) </autoit> any help is greatly appreciated!!!
  4. Hey Guys, So, the functions work, where primarygui() accurately determines the evaluation of the status of the checkboxes - the msgbox picks this up. However, later on, when we re-enter a 'for $i = 0 to ubound($checkbox)' loop, then in the 'batchinitial' function it doesn't picked up that the status&$i = 1, so it jumps out, then within the While 1 loop, it exits the loop in the first row, again because the status& $i= 0 The "assign" line within the primarygui funtion, is this only a local assignment? if so, how can I make it cross function? Thank in adv for your help Func excelsheetlist() $i = 0 Global $aWorkSheets = _Excel_SheetList($oWorkbook1) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_SheetList Example 1", "Error listing Worksheets." & @CRLF & "@error = " & @error & ", @extended = " & @extended) ;_ArrayDisplay($aWorkSheets, "Excel UDF: _Excel_SheetList Example 1") ;_ArrayDisplay($aWorkSheets, "Array") Global $iRows = UBound($aWorkSheets, $UBOUND_ROWS) ; Total number of rows. In this example it will be 10. Global $iCols = UBound($aWorkSheets, $UBOUND_COLUMNS) ; Total number of columns. In this example it will be 20. Global $iDimension = UBound($aWorkSheets, $UBOUND_DIMENSIONS) ; The dimension of the array e.g. 1/2/3 dimensional. MsgBox($MB_SYSTEMMODAL, "", "The array is a " & $iDimension & " dimensional array with " & _ $iRows & " row(s) & " & $iCols & " column(s).") Dim $checkbox[$iRows] EndFunc ;==>excelsheetlist Func primarygui() ; Create a GUI with various controls. Local $hGUI = GUICreate("Script Controller", 300, ($iRows * 24)) ; Create a checkbox control. ;Local $idCheckbox = GUICtrlCreateCheckbox("Standard Checkbox", 10, 10, 185, 25) Local $Button2 = GUICtrlCreateButton("Close", 210, 200, 85, 25) Local $Button3 = GUICtrlCreateButton("Run", 210, 170, 85, 25) Local $Button1 = GUICtrlCreateButton("Discharge", 210, 140, 85, 25) For $i = 0 To UBound($checkbox) - 1 $checkbox[$i] = GUICtrlCreateCheckbox($aWorkSheets[$i][0], 8, 0 + ($i * 24)) ;, 81, 17) Next ; Display the GUI. GUISetState(@SW_SHOW, $hGUI) ; Loop until the user exits. While 1 $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE Exit Case $nMsg = $Button2 ;Close Exit Case $nMsg = $Button1 MsgBox(0, "Discharge Button not configured", "Now Exiting") Exit Case $nMsg = $Button3 ;Run $fSelection = False For $i = 0 To UBound($checkbox) - 1 If BitAND(GUICtrlRead($checkbox[$i]), $GUI_CHECKED) Then $fSelection = True ExitLoop EndIf Next If $fSelection Then For $i = 0 To UBound($checkbox) - 1 Assign("status" & $i, GUICtrlRead($checkbox[$i])) Next $batchcount = 0 For $i = 0 To UBound($checkbox) - 1 If Eval("status" & $i) = 1 Then $batchcount = $batchcount + 1 ;Call ("o" & $i & "copy") ; if you want to call the functions directly, remove ; before the call and comment or delete the following DirCopy statement MsgBox(0, "Checking", "Checking that: " & $checkbox[$i] & " no, with title: " & $aWorkSheets[$i][0] & " was selected, Batch count: " & $batchcount) ; if you need only the DirCopy EndIf Next ExitLoop Else MsgBox(48, 'No Items Selected', 'You have not selected any Patients to Load, Please select from the list') EndIf EndSelect WEnd ; Delete the previous GUI and all controls. GUIDelete($hGUI) EndFunc ;==>primarygui Func _IsChecked($idControlID) Return BitAND(GUICtrlRead($idControlID), $GUI_CHECKED) = $GUI_CHECKED EndFunc ;==>_IsChecked Func batchinitial() If Eval("status" & $i) = 1 Then debugbox() $oWorkbook1.Sheets(1).Activate $bigloop = $bigloop + 1 $sheet = $aWorkSheets[$i][0] $oWorkbook1.Sheets($sheet).Activate debugbox() EndIf EndFunc ;==>batchinitial OpenExcel() excelsheetlist() primarygui() For $i = 0 To UBound($checkbox) - 1 batchinitial() While 1 If Eval("status" & $i) = 0 Then ExitLoop ;all the rest of my script loops etc WEnd Next
  5. Hello! Can anyone explain what's going on here: ; Initializing an array Local $a = [ 0 ] ; Lately in code I want to assign new array to $a variable $a = [ 1 ] and got this error at compile time ==> Error in expression.: $a = [ 1 ] $a = ^ ERROR What is it and why? And I've mentioned that I can't pass "manual" array to function as parameter: a( [ 0 ] ) Func a( $a ) _ArrayDisplay( $a ) EndFunc still the same error ==> Error in expression.: a( [ 0 ] ) a( ^ ERROR
  6. Hello, I need to assign data to array: Global $Test[3][4] $Array = "Test" SetArrayData($Array,"Hello world!",1,3) ConsoleWrite($Array[1][3]&@CRLF) Exit Func SetArrayData($Array,$Data,$1,$2) $Array[$1][$2] = $Data; <-- ??? EndFunc I need that somebody would help me with that function
  7. Hello! I havent found any solution for my problem in the Internet or on the Forum, excuse me If i overlooked something. For $i = 1 To 5 Assign("oGoogle"&$i, _IECreate("google.com" 0, 1, 0, 0)) $GoogleVar = $oGoogle&$i Assign("oSearchInput"&$i, _IEGetObjById($GoogleVar, "lst-ib")) NextWhat I'am trying to do is open Google.com 5 times with _IECreate and assign it to the Variables "$oGoogle1, $oGoogle2,...", but I have to use these Variables again, because I want to assign the Searchinputs from every $oGoogle to another Variable ($oSearchInput1, $oSearchInput2,...). But if i try to use this code, Autoit tells me that $oGoogle is not declared! I hope someone is willing to help me! (Excuse my Grammar )
  8. Im using assign to call some variables and at runtime I am getting errors: WARNING: $Reserve_1: possibly used before declaration. ERROR: $Reserve_1: undeclared global variable. The code below is how I assign the vars, and I used a 'IsDeclared' to verify that it was successful. Im trying to clean/convert old code and I would like to get rid of these 60 errors and 60 warnings thanks. For $i = 1 to 60 if not Assign ( "Reserve_"&$i, "",2) then MsgBox(0,"Error Assigning :","Reserve_"&$i) else ;MsgBox(0,"Assigning :","Reserve_"&$i) EndIf Next msgbox(0,'IsDeclared ( Reserve_58 )',IsDeclared ( 'Reserve_58' ))
  9. While i am waiting for Better Solutions for Finding Multiple @error Cases and React according to them, i am hoping that some1 could explain me what my problem in this (time consuming) function is.. The Idea is that i check for @Errors from the 3 PixelSearch i am doing, and give Message according to it. I am changing Colors In Paint for Every Loop To Test If the Color Searches Are Correct. All Cases are Working Fine, and the Right MsgBoxes are Triggered, Except the Case where all 3 Colors are Missing: HotKeySet("{ESC}", "End") Global $pixelSearchError1 = @error Global $pixelSearchError2 = @error Global $pixelSearchError3 = @error While 1 Sleep(10) $pixelsearch1 = PixelSearch(100,300,200,512,0x0000ff,10) ;Blue $pixelSearchError1 = @error $pixelsearch2 = PixelSearch(250,310,400,512,0xfa0000,10) ;Red $pixelSearchError2 = @error $pixelsearch3 = PixelSearch(500,300,600,512,0x00ff00,10) ;Green $pixelSearchError3 = @error Call("_errorcheck") WEnd Func _errorcheck() Sleep(100) Select ;Check for Blue Color, Then Proceed. Case Not $pixelSearchError1 ;Found Blue MsgBox(0,"Message","Blue Pixel Found!") Select ;Blue Found. Now check for Red Case Not $pixelSearchError2 ;Found Blue and Red MsgBox(0,"Message","Blue and Red Pixel Found!") Select ;Blue and Red found. Now check for Green Case Not $pixelSearchError3 ;Found Blue, Red and Green MsgBox(0,"Message","Blue,Red and Green Pixel Found!") Case $pixelSearchError3 ;Blue, Red But not Green MsgBox(0,"Message","Found Blue, Red But Not Green") EndSelect Case $pixelSearchError2 ;Blue Found, But Not Red MsgBox(0,"Message","Blue Found, But Not Red") Select ;Blue and Red found. Now check for Green Case Not $pixelSearchError3 ;Found Blue, Green But not Red MsgBox(0,"Message","Found Blue, Green But Not Red") Case $pixelSearchError3 ;Blue, But not Red or Green MsgBox(0,"Message","Could only Find Blue") EndSelect EndSelect Case $pixelSearchError1 ;Blue Not Found MsgBox(0,"Message","Blue Pixel Not Found") Select ;Blue Not Found. Now check for Red Case Not $pixelSearchError2 ;Found Red, But not Blue MsgBox(0,"Message","Found Red, But not Blue") Select ;Found Red, But not Blue Now check for Green Case Not $pixelSearchError3 ;Red and Green, but not Blue MsgBox(0,"Message","Red,Green But not Blue") Case $pixelSearchError3 ;Red, But not Blue or Green MsgBox(0,"Message","Could only Find Red") EndSelect Case $pixelSearchError2 ;Could not find Blue or Red MsgBox(0,"Message","Could not Find Blue and Red") Select ;Blue and Red Not found. Now check for Green Case Not $pixelsearch3 ;Only found Green MsgBox(0,"Message","Only found Green") Case $pixelSearchError3 ;Did not Find Blue,Red or Green MsgBox(0,"Message","No Color was found") EndSelect EndSelect EndSelect Sleep(10) EndFunc I Made a Picture that should make it far easier to see where one Select Case Starts and Ends Check the Link Below. http://imageshack.us/f/9/selectcasegreenerror.gif/ I can't see why the Last Case is not working.. When Blue,Red AND Green are Missing i still get the "Only found Green" Please Help Also, Building the Cases Like this takes up allot of Time and Space, so if you have a Easier way please Tell Like: If Not @error 1 And @error 2 And @error 3 Then But i don't think that Works. I probably want to run 5 PixelSearches and that would mean 5 Select an 32 Cases !!!1!!11 So it would be Great if there was another way of doing this If not, Please do still tell what the problem of my Function is
×
×
  • Create New...