Lists and @transform?

I will apologize in advance for my brain power has been squeezed a bit by my newborn child. I will first mention that I have spent some time trying to sort this out on my own (using the help, searching the forum, blah blah). I am not asking for someone to do this for just point me in the right direction please…

The nitty gritty: I have some fields:

item1

category1

item2

category2

item3

category3

item4

category4

The category fields roll up into a @unique(list1)

Should I/Can I use @transform to display the list of unique categories one by one followed by the list of items which have

the coressponding category field selected?

ie

item1 = “red”

category 1 = “color”

item2 = “dog”

category2 = “pet”

item3 = “blue”

category3 = “color”

item4 = “happy”

category4 = “emotion”

should display as:

color

red

blue

pet

dog

emotion

happy

Any help steering me in the most efficient direction is greatly appreciated.

Elijah

Subject: RE: Lists and @transform?

categories := category1:category2:category3:category4;items := item1:item2:item3:item4;

combined := categories + “!” + items;

uniqCats := @Unique(categories);

@Transform(uniqCats; “x”; x + @newline + @Implode(@Trim(@right(combined; x + “!”)); @Newline))

Subject: RE: Lists and @transform?

Thank You both so much. I was on the right track but not getting over the hump.
Andre I wish my brain worked like yours :). The big thing messing me up was the
formatting I would still be lost without the @trim. Anyways I have added some
basic formatting if anyone else is interested. The formula with the formatting
I ended up with is:

categories:=@Trim(category1:category2:category3);
items:=item1:item2:item3;

combined := categories + “!” + items;
uniqCats := @Unique(categories);

@Implode(@Transform(uniqCats; “x”; @NewLine + “b>]” + x + “/b>]” +
@NewLine + @Implode(@Trim(@Right(combined; x + “!”))+ @NewLine)); @NewLine)

Subject: RE: Lists and @transform?

Slick…

I was thinking of using a c ! i but couldn’t remember the syntax (which was @right) to trim it out…

Mike

Subject: Lists and @transform?

Hello Elijah, a couple of ideas.

I’m not sure transform would be the best approach. You might want to use @for loops to examine each element. You can get your unique list of categories, and stick that in a unique_category list. Then make a list of cateogries and a list of items. Each positional element in the categories and items list should match up. Your outer for loop will loop through the unique_categories, your inner for loop will loop through each element in the category list, checking for a match against the currently indexed unique_category. I guess you can then print out the category header, then the items that match.

That’s my thought after a few minutes of thinking about it, however I’m sure there’s a more elegant solution :slight_smile:

Mike Robinson

http://www.invcs.com