Page 1 of 1

stupid question about set props

Posted: Thu Mar 23, 2006 6:40 pm
by Ultima
i was try to make function to remove particular thing from the prop
for example

Code: Select all

lets say nnn := {John, Ultima, Online, etc };
setglobalproperty("Names", nnn);
i wanna erase just john from "Names"
take in consideration names will be random that was just example
thanks alot

Posted: Thu Mar 23, 2006 7:12 pm
by Austin

Code: Select all

function RemoveFromArray(byref x_array, match)
    foreach index in (x_array)
            if ( index == match )
                   x_array.Erase(_index_iter);
                   return 1;
            endif
            sleepms(2);
    endforeach
    return 0;
endfunction

Posted: Tue Mar 28, 2006 7:58 am
by Althalus

Code: Select all

var nnn := {John, Ultima, Online, etc };
var new_array := RemoveElement(nnn, [position 4 example 1]);
setglobalproperty("Names", new_array);

Code: Select all

function RemoveElement(byref arry, position)
  var newarray := { };
  foreach thing in arry
    if(thing != arry[position])
      newarray.append(thing);
    endif
  endforeach
  return newarray;
endfunction

Posted: Wed Mar 29, 2006 4:37 am
by CWO
Althalus are you trying to erase a specific index passed to RemoveElement?

Whats wrong with what Austin used in array.erase(position number) ?

Posted: Wed Mar 29, 2006 10:41 am
by Tritan
Can you use the .Erase function in POL95? I was not aware of this and it would make some of my scripts alot easier to handle if it is possible.

Posted: Fri Mar 31, 2006 6:10 am
by CWO
Its existant in 095 I definitely know that. And I'm pretty sure I used it then too.