jhonford1 Posted April 2, 2018 Share Posted April 2, 2018 for some reason i cant use redim inside execute and i also can't assign values to the array using it any ideas? example: #include <array.au3> Global $test[3] = [1,2,3] _ArrayDisplay($test) Execute("ReDim $test[0]") _ArrayDisplay($test) expected outcome: an array of [0] size also Execute("$test[0] = 5") doesn't seem to do anything Link to comment Share on other sites More sharing options...
BrewManNH Posted April 3, 2018 Share Posted April 3, 2018 Why in the world are you using Execute? If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
jdelaney Posted April 3, 2018 Share Posted April 3, 2018 (edited) You can't redim any array to [0]...what you want is to just set the value of the variable = "" (maybe?). If not, then what you are trying to do is not clear. Edited April 3, 2018 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. Link to comment Share on other sites More sharing options...
jchd Posted April 3, 2018 Share Posted April 3, 2018 4 minutes ago, jdelaney said: You can't redim any array to [0] Yes you can! 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 hereRegExp tutorial: enough to get startedPCRE 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) Link to comment Share on other sites More sharing options...
spudw2k Posted April 3, 2018 Share Posted April 3, 2018 5 minutes ago, jdelaney said: You can't redim any array to [0] Technically you can ReDim to [0]...I'm just not sure the usefulness or application where you would need to do this. 2 hours ago, BrewManNH said: Why in the world are you using Execute? I am also curious. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
jdelaney Posted April 3, 2018 Share Posted April 3, 2018 (edited) Huh, was that always the case? Interesting. Well, you definitely can't assign value to an array with ubound=0. (prove me wrong with some 'new' way) Edited April 3, 2018 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. Link to comment Share on other sites More sharing options...
jchd Posted April 3, 2018 Share Posted April 3, 2018 It's plain obvious you can't store anything in an array having been declared as containing zero row and this is exactly why they're useful! Despite being unable to store anything empty arrays have their use: You don't have to declare an array with an inexact number of rows (or first dimension) in numerous cases where you're going to accumulate results there, w/o having the faintest idea how many you'll have to store, if any. This allows to satisfy a useful invariant of the function, saying that both $aResult and UBound($aResult) always match what has been processed so far. A function returning an array can do so in any case where there is no result, conforming to a more simple specification. Many functions created before empty arrays were available used to return an error in such case; this is technically wrong. I believe (without being definitely positive) that COM objects may accept and/or return Nul arrays, which easily translates into AutoIt empty array. If memory serves at my age, it's for that or similar reason that empty arrays were introduced. Empty arrays are consistent at first-order with OO containers (lists, bags, queues, arrays, fifos, sets, whatever): when you create an instance of such a beast it's initially empty. An error should only ever mean that the function hit an abnormal condition where it can't perform it's intended job. It generally isn't abnormal to find no match for a search. Easy idealized example: _FileListToArray("没有这样的目录") ; is likely to return an error 1 (text means "No such directory") _FileListToArray(".", "没有这样的文件") ; shouldn't return an error but an empty array (text means "No such file") Of course this example is bad, since the function is currently specified to return an array with the number of entries in row 0 (another design error in my view, but too late to fix). Changelog says: 3.3.10.0 (23rd December, 2013) (Release) Added: Empty arrays. 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 hereRegExp tutorial: enough to get startedPCRE 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) Link to comment Share on other sites More sharing options...
jhonford1 Posted April 3, 2018 Author Share Posted April 3, 2018 First thank you everyone for your replys now let me answer some of the question: Q:why do i need to resize them? A:basicly becasue i want to empty them (this is the task that was given to my by the original writer of the script) Q:why in the world do i have to use execute? A:becasue the names of the arrays that i need to empty come for another array(again im not the writer of the code). using execute was just an attempt if you have a better idea the sure i will delete my line Global $arraynames = ["$array1", "$array2", "$array3"] for $i= 0 to UBound($arraynames)-1 execute("ReDim" & " " & $arraynemaes[$i] & "[0]") Next i was thinking of using something like this to empty all of the arrays but it does'nt work note: i'm NOT allowed to change the original code in any way therefore i have to find a way using what i have and i can't post the script as well :/ also now im really curious why the the execute function failed in my attaempt Link to comment Share on other sites More sharing options...
Subz Posted April 3, 2018 Share Posted April 3, 2018 Probably not the best method but you could do something like: #include <Array.au3> Global $aArray1[4] = [3,1,2,3] Global $aArray2[4] = [3,1,2,3] Global $aArray3[4] = [3,1,2,3] _ArrayDisplay($aArray1, "Before") _ArrayDisplay($aArray2, "Before") _ArrayDisplay($aArray3, "Before") Global $aArrayNames = ["$aArray1", "$aArray2", "$aArray3"] For $i = 0 to UBound($aArrayNames)-1 For $j = UBound(Execute($aArrayNames[$i])) - 1 To 0 Step - 1 Execute("_ArrayDelete(" & $aArrayNames[$i] & ", " & $j & ")") Next Next _ArrayDisplay($aArray1, "After") _ArrayDisplay($aArray2, "After") _ArrayDisplay($aArray3, "After") Link to comment Share on other sites More sharing options...
jhonford1 Posted April 3, 2018 Author Share Posted April 3, 2018 13 minutes ago, Subz said: Probably not the best method but you could do something like: #include <Array.au3> Global $aArray1[4] = [3,1,2,3] Global $aArray2[4] = [3,1,2,3] Global $aArray3[4] = [3,1,2,3] _ArrayDisplay($aArray1, "Before") _ArrayDisplay($aArray2, "Before") _ArrayDisplay($aArray3, "Before") Global $aArrayNames = ["$aArray1", "$aArray2", "$aArray3"] For $i = 0 to UBound($aArrayNames)-1 For $j = UBound(Execute($aArrayNames[$i])) - 1 To 0 Step - 1 Execute("_ArrayDelete(" & $aArrayNames[$i] & ", " & $j & ")") Next Next _ArrayDisplay($aArray1, "After") _ArrayDisplay($aArray2, "After") _ArrayDisplay($aArray3, "After") I was thinking of something similar tbh, but i still dont understand why my method failed :/ Link to comment Share on other sites More sharing options...
BrewManNH Posted April 3, 2018 Share Posted April 3, 2018 Are you trying to empty the arrays, or delete them? Because you can use $array = "" to empty an array and turn it into a simple variable. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Developers Jos Posted April 3, 2018 Developers Share Posted April 3, 2018 15 hours ago, BrewManNH said: Why in the world are you using Execute? Did we get an answer on this pretty basic question as I have no clue why it is used in all those scripts posted yet? Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
jhonford1 Posted April 3, 2018 Author Share Posted April 3, 2018 1 hour ago, BrewManNH said: Are you trying to empty the arrays, or delete them? Because you can use $array = "" to empty an array and turn it into a simple variable. I know that i can do that how ever how do you use it multiple arrays? (The script will decide which arrays to delete at run time i can't write it manually ) 18 minutes ago, Jos said: Did we get an answer on this pretty basic question as I have no clue why it is used in all those scripts posted yet? Jos Yes, i've already answered this question 8 hours ago, jhonford1 said: Q:why in the world do i have to use execute? A:becasue the names of the arrays that i need to empty come for another array(again im not the writer of the code). using execute was just an attempt if you have a better idea the sure i will delete my line Link to comment Share on other sites More sharing options...
BrewManNH Posted April 3, 2018 Share Posted April 3, 2018 You can't use Execute to declare or redeclare a variable. another question that comes to mind, WHY do you need to delete these arrays? What's wrong with just leaving them there? 8 hours ago, jhonford1 said: note: i'm NOT allowed to change the original code in any way therefore i have to find a way using what i have and i can't post the script as well Then isn't all of this a moot point anyways? You're trying to change the code, but you're not allowed to change the code? That's a very confusing issue you have there. Earthshine 1 If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
jhonford1 Posted April 3, 2018 Author Share Posted April 3, 2018 47 minutes ago, BrewManNH said: Then isn't all of this a moot point anyways? You're trying to change the code, but you're not allowed to change the code? That's a very confusing issue you have there. i need to write a piece of code that work with the existing script without modifying it (just adding my piece to the script) Link to comment Share on other sites More sharing options...
Developers Jos Posted April 3, 2018 Developers Share Posted April 3, 2018 Why? I would prefer doing it the right way in stead of mickey mousing around ... no? Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
BrewManNH Posted April 3, 2018 Share Posted April 3, 2018 1 hour ago, jhonford1 said: i need to write a piece of code that work with the existing script without modifying it (just adding my piece to the script) Whoever wrote the original script (that you can't modify for some reason) needs to rewrite his/her part of it and make it work better, trying to code around someone else's ineptitude is bound to be frustrating. Earthshine 1 If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
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