stupid question about set props

Get Help on scripting in POL with configurations, config setups, script trouble shooting, etc.
Post Reply
Ultima

stupid question about set props

Post 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
User avatar
Austin
Former Developer
Posts: 621
Joined: Wed Jan 25, 2006 2:30 am

Post 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
Althalus
New User
Posts: 12
Joined: Fri Feb 17, 2006 5:34 pm

Post 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
User avatar
CWO
POL Expert
Posts: 1160
Joined: Sat Feb 04, 2006 5:49 pm

Post 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) ?
User avatar
Tritan
Grandmaster Poster
Posts: 147
Joined: Sat Feb 04, 2006 8:17 am

Post 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.
User avatar
CWO
POL Expert
Posts: 1160
Joined: Sat Feb 04, 2006 5:49 pm

Post by CWO »

Its existant in 095 I definitely know that. And I'm pretty sure I used it then too.
Post Reply