Notifications
Clear all

[Closed] Check 2 arrays and delete items

I have 2 arrays a1 and a2, i want to check and delete items ,here is my code , and it not work , please help me , thank

a1 = #($Box002, $Box003, $Box004, $Box001)
a2 = #($Box004, $Box001)
for j=a2.count to 1 by -1 do
(
deleteItem a1 a2[j]
)

3 Replies

deleteItem array index
index is number not node
you need use finditem to get the number

ok , i created deleteItem2 function , thank you very much

fn deleteItem2 barr sarr = (
i = 0
idarr = #()
while i < barr.count do (
i+=1
for k = 1 to sarr.count do
(
if barr[i] == sarr[k] do
(
append idarr i
)
)
)
sort idarr
for j = idarr.count to 1 by -1 do
(
deleteItem barr idarr[j]
)
return barr
)

a11 = #(“$Box002”, “$Box003”, “$Box004”, “$Box001”)
a22 = #(“$Box004”, “$Box001”)
deleteItem2 a11 a22

fn GetAoutB asel bsel = 
	(
		for o in bsel where (n = finditem asel o) > 0 do deleteItem asel n
		asel
	)

this is the function about difference set of 2 arrays