Deleting One Item in a Text List

Tripp W Black on 08/26/1999 at 07:51 PM


Category: Notes Developer Tips
Forms/Subforms, Formulas

Author:
Don Shively
Date:
Wednesday, 8/04/99 10:50 PM EDT
Subject:
Deleting one element from a list
Category:
LotusScript - Code Request




I have a list of names in a field on a document that is generated from a profile. I want to remove the second
name using an action button. I have tried remove.item but this removes the whole field. Any help is much
appreciated.


******************************* Solution 1 ****************************************
Author:
Greg Douglass
Date:
Thursday, 8/05/99 5:25 AM EDT
Subject:
Re: Deleting one element from a list




Try This


items = notesitem.values
forall i in items
if i = "value to remove" then
i = ""
end if
next
notesitem.values = items

Greg.
Greg_Douglass@hotmail.com

******************************* Solution 2 ****************************************
Author:
Jo Bruce
Date:
Thursday, 8/05/99 6:50 AM EDT
Subject:
Re: Deleting one element from a list




This is using formulas rather than script....

It is the formula behnd a Remove Entry button for a dynamic table so it is removing one value in the same
position from several fields :


Items := @Elements(CMNo);
@If(@IsDocBeingEdited; ""; @Command([EditDocument])) ;
LNo := @If(Items > 1; @TextToNumber(@Prompt([OKCANCELEDIT]; "Car Mileage Information - Remove Entry.";
"Enter the Number of the row that you wish to Remove. There are " + @Text(Items) + " rows available."; 0));
1);
@If(Lno > Items | Lno <= 0; @Do(@Prompt([OK]; "Car Mileage Information. Error."; "Invalid Number. The number
MUST be between 1 and " + @Text(Items) + "."); @Return(0)); "");

FIELD CMNo := @If(Items = 1; @DeleteField; @Subset(CMNo; Items - 1));

FIELD CMDate := @If(Items = 1; @DeleteField; LNo = 1; @Subset( CMDate; Lno - Items) ; LNo > 1 & LNo !=
Items; @Subset( CMDate; Lno - 1 ) : @Subset( CMDate; LNo - Items); LNo = Items; @Subset(CMDate; Items -
1); "");
FIELD CMFrom := @If(Items = 1; @DeleteField; LNo = 1; @Subset( CMFrom; Lno - Items) ; LNo > 1 & LNo !=
Items; @Subset( CMFrom; Lno - 1 ) : @Subset( CMFrom; LNo - Items); LNo = Items; @Subset(CMFrom; Items -
1); "");
FIELD CMTo := @If(Items = 1; @DeleteField; LNo = 1; @Subset( CMTo; Lno - Items) ; LNo > 1 & LNo != Items;
@Subset( CMTo; Lno - 1 ) : @Subset( CMTo; LNo - Items); LNo = Items; @Subset(CMTo; Items - 1); "");
FIELD CMMiles := @If(Items = 1; @DeleteField; LNo = 1; @Subset( CMMiles; Lno - Items) ; LNo > 1 & LNo !=
Items; @Subset( CMMiles; Lno - 1 ) : @Subset( CMMiles; LNo - Items); LNo = Items; @Subset(CMMiles; Items -
1); "");
FIELD CMvat := @If(Items = 1; @DeleteField; LNo = 1; @Subset( CMvat; Lno - Items) ; LNo > 1 & LNo != Items;
@Subset( CMvat; Lno - 1 ) : @Subset( CMvat; LNo - Items); LNo = Items; @Subset(CMvat; Items - 1); "");
FIELD CMPur := @If(Items = 1; @DeleteField; LNo = 1; @Subset( CMPur; Lno - Items) ; LNo > 1 & LNo != Items;
@Subset( CMPur; Lno - 1 ) : @Subset( CMPur; LNo - Items); LNo = Items; @Subset(CMPur; Items - 1); "");

@PostedCommand([ViewRefreshFields]);
NULL

Author:
cpinheiro@mail.quatrosi.pt
Date:
Thursday, 8/05/99 7:07 AM EDT
Subject:
Re: Deleting one element from a list


******************************* Solution 3 ****************************************

Hi.
You can assign the field contents to a variant. This variant will contain a list of values - all the items of the
field.
You can work this variant as an array. So, you can remove the items that you want and finally you assign the
variant to the field.
Example: this example will remove the 2ยบ item from the field x (the first position of the variant is 0)

v = doc.x
for i = 1 to UBound( v ) - 1
v( i ) = v( i + 1 )
next
redim v( UBound( v ) - 1 )
doc.x =v

Best regards
cpinheiro@mail.quatrosi.pt


previous page

mailcheck your mailaccountsclient loginportfolioportfoliohostinghostingpromopromossupporthelpaccountsSMS