Chu Posted October 18, 2008 Share Posted October 18, 2008 (edited) Hello all. I have a function that looks like this: Func ePC($coords) ... EndFunc It takes in a $something[4] and spit outs an integer. Elsewhere in my program I have a $something[5][4]. I was searching the forums, and apparently there is no way to do something like ePC($something[5][]). If this is wrong please correct me! I really can't believe in three versions noone has added this feature . . . Anyways, as a workaround, instead I have this: Dim $tmp_0[5] For $i = 0 to 4 Step 1 Dim $tmp_1[4] = [$watch_2[$i][0], $watch_2[$i][1], $watch_2[$i][2], $watch_2[$i][3]] $tmp_0[$i] = ePC($tmp_1) Next My question is about what "Dim" actually does. This is probably going to be running in a service and this code is going to be called hundreds of thousands of times, maybe millions. My question is if AutoIt either has a "delete" keyword so I can explicitly free that space, or if the garbage collector is smart enough to release that space on its own. Edited October 18, 2008 by Chu Link to comment Share on other sites More sharing options...
dbzfanatic Posted October 18, 2008 Share Posted October 18, 2008 There's an ArrayDelete() function and Dim declares a variable for use. Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
Chu Posted October 18, 2008 Author Share Posted October 18, 2008 There's an ArrayDelete() function and Dim declares a variable for use.Where is ArrayDelete() exactly? I'm having trouble finding it in the official docs.My question is what does "declare" mean exactly. I assume it's allocating space on the heap dynamically at runtime which means it just sits there until something explicitly kills it. Link to comment Share on other sites More sharing options...
BrettF Posted October 18, 2008 Share Posted October 18, 2008 (edited) Declaring in a nutshell for a arrays means defining the name of the variable, and the elements the array has. You decalre it in one of 3 scopes, just like normal variables- Global, Dim (Local if variable not global), Local. Check this out for declaring. Dim $array[10]; Array with 10 elements. $array[0] = "Something" MsgBox (0, "", $array[0]) You can find _ArrayDelete() in the UDF section of the helpfile, under Array Management. Cheers, Brett Edited October 18, 2008 by BrettF Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
Malkey Posted October 18, 2008 Share Posted October 18, 2008 Hello all. I have a function that looks like this: Func ePC($coords) ... EndFunc It takes in a $something[4] and spit outs an integer. Elsewhere in my program I have a $something[5][4]. I was searching the forums, and apparently there is no way to do something like ePC($something[5][]). If this is wrong please correct me! I really can't believe in three versions noone has added this feature . . . Anyways, as a workaround, instead I have this: Dim $tmp_0[5] For $i = 0 to 4 Step 1 Dim $tmp_1[4] = [$watch_2[$i][0], $watch_2[$i][1], $watch_2[$i][2], $watch_2[$i][3]] $tmp_0[$i] = ePC($tmp_1) Next My question is about what "Dim" actually does. This is probably going to be running in a service and this code is going to be called hundreds of thousands of times, maybe millions. My question is if AutoIt either has a "delete" keyword so I can explicitly free that space, or if the garbage collector is smart enough to release that space on its own. The help file under index tab find Local, It has some good information - find Array = 0 in Local 's documentation. Also ReDim backs up the info under Local in help file. So each time Dim $tmp_1[4] is run, the previous values in the array $tmp_1 are erased because of the Dim statement. And your work around is the way to go. I know nothing in AutoIt which allows anything like ePC($something[4][0 to 3]) for a 5x4 array What is possible is :- ePC($something) - pass entire array: or ePC($something[4][0], $something[4][1], $something[4][2], $something[4][3]) - Passing 4 parameters or more. Here is another possibility, Local $tmp_0[4] For $i = 0 To 3 $tmp_0[$i] = ePC($watch_2[$i][0], $watch_2[$i][1], $watch_2[$i][2], $watch_2[$i][3]) Next The ePC() function would need to modified. Func ePC($coord1, $coord2, $coord3, $coord4) Hope this helps. Link to comment Share on other sites More sharing options...
Chu Posted October 18, 2008 Author Share Posted October 18, 2008 (edited) Thanks a lot for the help. I really can't modify the function though, it's used mostly in it's written form in other functions and I don't think AutoIt supports overloading (does it?). Edited October 18, 2008 by Chu 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