Ilias48rus 32 Posted July 27, 2017 Is any way to delete all links to array (for it would be removed from memory by cleaner) having only 1 link to it, ex: a=[0,1,2,3,4,5,6,7,8,9]; a1=a; //forgeting a; |delete| a1; isnil'a'==true Share this post Link to post Share on other sites
sarogahtyp 1104 Posted July 27, 2017 idk if I got what u r trying but if i did then nil should it do simply? Share this post Link to post Share on other sites
Ilias48rus 32 Posted July 27, 2017 Just now, sarogahtyp said: idk if I got what u r trying but if i did then nil should it do simply? no, a=[0,1,2,3,4,5,6,7,8,9]; a1=a; a1=nil; hint str a a1=nil is setting up a1==nil not the array ([0,1,2,3,4,5,6,7,8,9]), the array is in memory and not is a or a1, its just links to it. Share this post Link to post Share on other sites
sarogahtyp 1104 Posted July 27, 2017 I don't believe that. AFAIK the array is destroyed right after the last reference is niled... EDIT: see Mikero's note on nil page! 1 Share this post Link to post Share on other sites
Ilias48rus 32 Posted July 27, 2017 8 minutes ago, sarogahtyp said: I don't believe that. AFAIK the array is destroyed right after the last reference is niled... Yes, probably, as far as i know too, but the question is: how to delete array (delete all the links) if know only 1 of them ? 8 minutes ago, sarogahtyp said: see Mikero's not on nil page! + How to delete array (delete all the links) if know only 1 of them ? Share this post Link to post Share on other sites
sarogahtyp 1104 Posted July 27, 2017 I think u just should know all of them or be able to discover them. But if u don't it could be a try to use https://community.bistudio.com/wiki/allVariables and compare the content with ur one known variable. this would destroy all other arrays (or just their variables) which have exactly the same content as well and have varialbles in the same namespace but it could be a workaround anyway depending on the specific problem. I don't believe that there is a way to get the memory adress space and destroy the array directly for example. 1 Share this post Link to post Share on other sites
Ilias48rus 32 Posted July 27, 2017 8 minutes ago, sarogahtyp said: I think u just should know all of them or be able to discover them. But if u don't it could be a try to use https://community.bistudio.com/wiki/allVariables and compare the content with ur one known variable. this would destroy all other arrays (or just their variables) which have exactly the same content as well and have varialbles in the same namespace but it could be a workaround anyway depending on the specific problem. I don't believe that there is a way to get the memory adress and destroy the array directly for example. Yeap, compairing, + but its missed command, agree ?, it also (additionally to case when you don't know all links's names) would be useful for deleting arrays, because it would take 1 action instread of |_|=nil for each array's link. (I do understand what its not something very needeable, but still technically) Share this post Link to post Share on other sites
sarogahtyp 1104 Posted July 27, 2017 Its a thing of the point of view. It could cause access violations if a variable tries to access an adress which was freed before... I think I'm happy that a scripter has not much to care about adress spaces and how to allocate and free it. Don't forget that sqf is a scripting and not a programming language. Share this post Link to post Share on other sites
Ilias48rus 32 Posted July 27, 2017 13 minutes ago, sarogahtyp said: Its a thing of the point of view. It could cause access violations if a variable tries to access an adress which was freed before... I think I'm happy that a scripter has not much to care about adress spaces and how to allocate and free it. Don't forget that sqf is a scripting and not a programming language. i said command to unassign all variables linking to the array and delete the array, not to delete the array and keep them all broked. Its 1 of things why i'm not happy with other languages, the huge mount of coding all the time for the technical supply of the workground (allocating spaces, describing how do do something additionally to just writing to do it..) ps.(i do know difference with languages's levels (do not describe it with another post please)) Share this post Link to post Share on other sites
sarogahtyp 1104 Posted July 27, 2017 Okay maybe such command would be handy in some few cases. But in which case do u need that?The most arrays I create are local in a script's scope and get destroyed if the script ends.Those which need global context are these I watch all the time and I know all of their variable names which is only one mostly...sent from mobile using Tapatalk 1 Share this post Link to post Share on other sites
Ilias48rus 32 Posted July 27, 2017 10 minutes ago, sarogahtyp said: Okay maybe such command would be handy in some few cases. But in which case do u need that? The most arrays I create are local in a script's scope and get destroyed if the script ends. Those which need global context are these I watch all the time and I know all of their variable names which is only one mostly... sent from mobile using Tapatalk For example in my comm script, if i'll finish it probably would be useful to write it in uninit script for deleting data arrays, they would have hundreds of items in them (deleting would be bit justified) and despite it wouldn't be difficult to find all links, it could be easier to write delete |most used link 's name| (global arrays usualy have local links, pereodicialy unmentionable (each time you writing _a=a for example, making new link)) Share this post Link to post Share on other sites
sarogahtyp 1104 Posted July 27, 2017 but why do ur data arrays need more than one single global variable name? Share this post Link to post Share on other sites
Ilias48rus 32 Posted July 27, 2017 11 minutes ago, sarogahtyp said: but why do ur data arrays need more than one single global variable name? Deal not in its's names, deal in links which leading to arrays which is parts of the arrays, there can be alot of them, ex: a=[[0],[1] //.. ]; a1=a select 0; a2=a select 1; a select 0 pushback 1; //.. a=nil; systemchat str a1; systemchat str a2 //.. its even IF parts of array which can't be accessed getting deleted, need to find all the links to it's other parts in scripts Share this post Link to post Share on other sites
sarogahtyp 1104 Posted July 27, 2017 I personally avoid such thing with holding those partial array local to the script which needs a part. I have just one global array and in a script i would just do: MyGlobalArray params ["_posA", "_posB", "_some_settings"]; _posA params ["_xA", "_yA", "_zA"]; _posB params ["_xB", "_yB", "_zB"]; _some_settings params ["_cam_obj", "_camVdir", "_camVup"]; and so on ... this way I get only local variablenames which get destroyed automatically and have only one single MyGlobalArray which I would destroy after all other scripts which use data from it have finished... Share this post Link to post Share on other sites
Ilias48rus 32 Posted July 27, 2017 37 minutes ago, sarogahtyp said: I perso.. Its other, i'm talking about not simple, global arrays, for example command tree, whole tree is, and parts of it which containing groups under units's command can be assigned to global variables for speeding access when working with the units, and yes can say the parts can be described: just like other global arrays; but still easier to write one command to delete whole hierarchy Share this post Link to post Share on other sites
sarogahtyp 1104 Posted July 27, 2017 I'm very sorry and I won't blame you for sure but IMO it seems to be bad scripting habbits which cause your request. I did use deep, not simple arrays as well and I avoided to use more than one global variablename for each data array anyways... The above code I posted is just a simple example but it could be expanded to a complexity of your choice. I just think you don't really need much (or even one single) global subarrays... Share this post Link to post Share on other sites
Ilias48rus 32 Posted July 27, 2017 32 minutes ago, sarogahtyp said: I'm very so.. You just didn't worked with pertinent systems, while it probably still can be possibly to make only setting local arrays in each script and using cross passing links between them there can be situations where you'll |should|need to| set the global link to array's part, ex: Player open interface with tree showing it's subordinates, on creation dialog calling the array which is part of global command tree. , also can be other scripts from other systems which will continue running, having in memory local links to array which you want to delete Share this post Link to post Share on other sites
Dedmen 2583 Posted August 25, 2017 you can just resize 'a' to 0. then 'a1' will contain an empty array. But no. You can't delete other links to an array. Share this post Link to post Share on other sites
Ilias48rus 32 Posted August 25, 2017 6 hours ago, dedmen said: you can just resize 'a' to 0. then 'a1' will contain an empty array. But no. You can't delete other links to an array. thanks for answer, sadly :( , through offered by you solution isn't bad still hope what the functionality possibly will be implemented Share this post Link to post Share on other sites
Dedmen 2583 Posted August 25, 2017 4 hours ago, Ilias48rus said: still hope what the functionality possibly will be implemented As I wrote in your Feedback tracker thingy that is impossible because engine. And also is not needed because if you want the array to go away. You can use the resize thingy as I've told you. 1 Share this post Link to post Share on other sites
Ilias48rus 32 Posted August 25, 2017 1 hour ago, dedmen said: As I wrote in your Feedback tracker thingy that is impossible because engine. And also is not needed because if you want the array to go away. You can use the resize thingy as I've told you. it will not go away just will be very small, just do not start another discussion about it please ) (and i wrote, the solution is not bad) Share this post Link to post Share on other sites