Jump to content
  • 0

unset array


Feefty

Question


  • Group:  Members
  • Topic Count:  47
  • Topics Per Day:  0.01
  • Content Count:  175
  • Reputation:   14
  • Joined:  11/21/11
  • Last Seen:  

how do you destroy or unset an array?

Thanks.

Link to comment
Share on other sites

7 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  26
  • Topics Per Day:  0.01
  • Content Count:  331
  • Reputation:   63
  • Joined:  11/29/11
  • Last Seen:  

cleararray @array[0],0,127;

This will turn all values till [127] to 0

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  205
  • Reputation:   19
  • Joined:  10/12/12
  • Last Seen:  

oh was too slow :P

Edited by Ryokem
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  379
  • Reputation:   304
  • Joined:  11/10/11
  • Last Seen:  

You can even use deletearray without to specify index or size.

deletearray .array;

  • Upvote 2
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  47
  • Topics Per Day:  0.01
  • Content Count:  175
  • Reputation:   14
  • Joined:  11/21/11
  • Last Seen:  

Thanks.

Edit: How do you remove a single element? i tried deletearray .array[1], 1; // didnt work

Edited by Feefty
Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10015
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  

@Freefty

refer this Deletearray

in your script it will remove the .array[1] value ..

if you want to know whether the array is deleted or value is removed...you can simple perform a check on the array..

for( set .@i,0; .@i < getarraysize( .array ); set .@i,.@i + 1 )
   dispbottom ".array["+.@i+"] = "+.array[.@i];

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.01
  • Content Count:  666
  • Reputation:   93
  • Joined:  04/27/12
  • Last Seen:  

To clean a single value in an array use:

cleararray .@arrary[1],0,1;
OR
set .@array[1],0;

Either one of those will work, additionally, you can use copyarray to simply move values [2]->[127] down 1 thus, replacing [1] with [2], technically this removes [1]'s orignal value, but keeps the array in tact if you needed to add stuff to the end of the file. But the quick solotions i give in the code.

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  47
  • Topics Per Day:  0.01
  • Content Count:  175
  • Reputation:   14
  • Joined:  11/21/11
  • Last Seen:  

Thanks!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...