View previous topic :: View next topic |
Author |
Message |
paboya How do I cheat?
Reputation: 0
Joined: 28 Apr 2013 Posts: 2
|
Posted: Sun Apr 28, 2013 5:31 pm Post subject: How to delete addresses |
|
|
hi, so i have this script to automatically add to address list
Code: | ...
...
local al=getAddressList()
local mr=addresslist_createMemoryRecord(al)
memoryrecord_setAddress(mr, saddress)
... |
my question is, how can i clear all found address from the list?
i try these script
Code: | function CEButton1Click(sender)
local al=getAddressList()
cnt = addresslist_getCount(al)
if cnt > 0 then
for i=0, cnt-1 do
local mr = addresslist_getMemoryRecord(al,i)
print("delete mr " .. i .. " " .. memoryrecord_getDescription(mr))
memoryrecord_delete(mr)
end
end
... |
but it only delete half of them
output:
Code: | delete mr 0 en1_0
delete mr 1 en1_2
delete mr 2 en1_4
delete mr 3 en1_6
delete mr 4 en1_8
Error:TTreeNodes.GetNodeFromIndex Index 5 out of bounds (Count=5)
|
but when i remove the "memoryrecord_delete" it loop perfectly?
|
|
Back to top |
|
 |
Dark Byte Site Admin
Reputation: 468
Joined: 09 May 2003 Posts: 25707 Location: The netherlands
|
Posted: Sun Apr 28, 2013 6:06 pm Post subject: |
|
|
when you delete an entry all subsequent indexes shift by 1 (so if you delete entry 0, 1 becomes 0, 2 becomes 1, etc...)
you're best of getting and deleting memory record 0 until the count is 0, or do a reverse for loop ( for i=cnt-1, 0 do )
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
 |
paboya How do I cheat?
Reputation: 0
Joined: 28 Apr 2013 Posts: 2
|
Posted: Sun Apr 28, 2013 6:16 pm Post subject: |
|
|
Dark Byte wrote: | when you delete an entry all subsequent indexes shift by 1 (so if you delete entry 0, 1 becomes 0, 2 becomes 1, etc...)
you're best of getting and deleting memory record 0 until the count is 0, or do a reverse for loop ( for i=cnt-1, 0 do ) |
thank for your sugggestions, the first work
Code: | while addresslist_getCount(al)>0 do
local mr = addresslist_getMemoryRecord(al,0)
memoryrecord_delete(mr)
end |
|
|
Back to top |
|
 |
mgr.inz.Player I post too much
Reputation: 221
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Mon Apr 29, 2013 5:56 am Post subject: |
|
|
memory records have ID too. If you want to keep other memoryrecords, do something like this:
createMemoryRecords - will create new mr
removeAllCreatedMemoryRecords - will remove mr created with above function
Code: | al=getAddressList()
IDsOfCreatedMR = {}
function createMemoryRecords() --create 10 memory records
for a=1,10 do
local mr=addresslist_createMemoryRecord(al)
memoryrecord_setDescription(mr, 'memory record test '..a)
table.insert(IDsOfCreatedMR , memoryrecord_getID(mr) )
end
end
function removeAllCreatedMemoryRecords()
for _,v in pairs(IDsOfCreatedMR) do
local mr = addresslist_getMemoryRecordByID(al,v)
if mr~=nil then memoryrecord_delete(mr) end
end
end |
_________________
|
|
Back to top |
|
 |
|