delete a value from an Array

Questions, tips and tricks and techniques for scripting in Servoy

delete a value from an Array

Postby IT2Be » Fri Feb 27, 2004 3:54 pm

Is it possible to delete a value from an Array? If so, how can I do so?
Marcel J.G. Trapman (IT2BE)
SAN partner - Freelance Java and Servoy
Servoy Components - IT2BE Plug-ins and Beans for Servoy
ServoyForge - Open Source Components for Servoy
User avatar
IT2Be
Servoy Expert
 
Posts: 4766
Joined: Tue Oct 14, 2003 7:09 pm
Location: Germany

Postby patrick » Fri Feb 27, 2004 4:00 pm

patrick
 
Posts: 3709
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

Postby IT2Be » Fri Feb 27, 2004 4:38 pm

Thanks Patrick,

Gave that one a better look but when I do the following Servoy tells me splice is not a function

Code: Select all
var Groups = security.getGroups();

for ( var i = 0 ; i < Groups.getMaxRowIndex() ; i ++ )
{
   if (Groups.getValue(i, 2) == "Administrators")
   {
      Groups.splice(i, 1);
      break;
   }
}

application.setValueListItems("usergroups" , Groups.getColumnAsArray(2), Groups.getColumnAsArray(1));
Marcel J.G. Trapman (IT2BE)
SAN partner - Freelance Java and Servoy
Servoy Components - IT2BE Plug-ins and Beans for Servoy
ServoyForge - Open Source Components for Servoy
User avatar
IT2Be
Servoy Expert
 
Posts: 4766
Joined: Tue Oct 14, 2003 7:09 pm
Location: Germany

Postby patrick » Fri Feb 27, 2004 5:59 pm

I haven't tested it, but I think you need to make sure that you really have a Java Script array. To me it looks like security.getGroups() is a Javaarray. I ran across the same problem. See the response from Johan in that discussion and what was my workaround. It should work then...
patrick
 
Posts: 3709
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

Postby IT2Be » Fri Feb 27, 2004 6:09 pm

Yes I have read that. In that case I have to build the array again and That is what I already do. I was just looking for a shortcut...
Marcel J.G. Trapman (IT2BE)
SAN partner - Freelance Java and Servoy
Servoy Components - IT2BE Plug-ins and Beans for Servoy
ServoyForge - Open Source Components for Servoy
User avatar
IT2Be
Servoy Expert
 
Posts: 4766
Joined: Tue Oct 14, 2003 7:09 pm
Location: Germany

Postby jcompagner » Sat Feb 28, 2004 12:11 pm

getGroups is not an array but a dataset.
it contains rows of multiply colums, so yes we could do it in an array but then you have to do things like:
array[row][column] xxx
instead of
ds.getValue(row,column)
the latter is a bit cleaner.
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8866
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Postby IT2Be » Mon Mar 01, 2004 1:03 pm

OK, no issue at all. Thanks for your answers...
Marcel J.G. Trapman (IT2BE)
SAN partner - Freelance Java and Servoy
Servoy Components - IT2BE Plug-ins and Beans for Servoy
ServoyForge - Open Source Components for Servoy
User avatar
IT2Be
Servoy Expert
 
Posts: 4766
Joined: Tue Oct 14, 2003 7:09 pm
Location: Germany


Return to Methods

Who is online

Users browsing this forum: No registered users and 7 guests

cron