hcl-bot
December 14, 2005, 10:56am
1
I’ve search the forum and tried various @formulas , but still can’t figure out how to do this…
I have a list with values, eg. “A” : “A” : “B” : “C” : “C” : “C” : “D”
and want to replace the duplicate entries with an empty string, but keep the first duplicate entry:
i.e. “A” : “” : “B” : “C” : “” : “” : “D”
Any suggestions?
hcl-bot
December 14, 2005, 12:13pm
2
Subject: Replace duplicate entries in list @Formula
Refer my other post —> “Here is the solution”
hcl-bot
December 14, 2005, 11:13am
3
Subject: Replace duplicate entries in list @Formula
Try @Unique .
/Peter
hcl-bot
December 14, 2005, 12:10pm
4
Subject: Replace duplicate entries in list @Formula
FIELD dlist := dlist;list := “A” : “A” : “B” : “C” : “C” : “C” : “D”;
temp := list[1];
nl := temp;
@For (n := 2; n <= @Elements (list); n := n + 1;
@If (list[n] = temp; nl:=nl:" ";@Do ( temp := list[n]; nl:=nl:temp))
);
@SetField (“dlist”; nl)
hcl-bot
December 14, 2005, 12:21pm
5
Subject: RE: Replace duplicate entries in list @Formula
Thanks Sergei, your code works great!
hcl-bot
December 14, 2005, 11:11am
6
Subject: Replace duplicate entries in list @Formula
Gary,
Will @Unique not do what you want?
Why do you need to keep empty entries where the duplicates were?
Mike
hcl-bot
December 14, 2005, 11:40am
7
Subject: RE: Replace duplicate entries in list @Formula
I’ve tried @Unique but I need to replace the duplicate entries with blank entries. What I’m trying to accomplish is to generate headings on a web page for documents using @DBlookups .
I have say 4 docs with the following fields
docA, Heading1
docB, Heading1
docC, Heading2
docD, Heading3
I do the following @DBLookups
List1 = “docA” : “docB” : “docC” : “docD”
List2 = “Heading1” : “Heading1” : “Heading2” : “Heading3”
I want to be able to display the lists in the following format
Heading1
docA
docB
Heading2
docC
Heading3
docD
Currently the following format is displayed:
Heading1
docA
Heading1
docB
Heading2
docC
Heading3
docD
I’m currently investigating other ways of getting the required format, but if I can replace unique entries with empty strings it will do what I want.
Hope I’ve explained what I’m trying to do - thanks for your previous responses.
hcl-bot
December 14, 2005, 3:41pm
8
Subject: Here is the solution
lst := “A” : “A” : “B” : “C” : “C” : “C” : “D”;
@For (n := 1; n <= @Elements (lst); n := n + 1;
tmp := @Subset (@Subset (lst; n);-1);
@If (n = 1; tmp1 := tmp; tmp1:= tmp1: @If (@IsMember (tmp; tmp1); “~”; tmp))
);
tmp1
tmp1 will be the result as A; ~; B; C; ~;~;D
If you remove ~ you will have spaces instead.