XMPie Remove Commas in VDP Line

Started by Slappy, December 31, 2020, 12:23:40 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Slappy

I know this is a Variable function I have to program, so this is the set of potential lines I'll have:

Quote<<TeachFirstName_1>> <<TeachLastName_1>>, <<COURSE_1>>, <<grade>>
<<TeachFirstName_2>> <<TeachLastName_2>>, <<COURSE_2>>, <<grade>>
<<TeachFirstName_3>> <<TeachLastName_3>>, <<COURSE_3>>, <<grade>>
<<TeachFirstName_4>> <<TeachLastName_4>>, <<COURSE_4>>, <<grade>>
<<TeachFirstName_5>> <<TeachLastName_5>>, <<COURSE_5>>, <<grade>>
<<TeachFirstName_6>> <<TeachLastName_6>>, <<COURSE_6>>, <<grade>>

Of course, not every student has ALL those teachers or courses, I need a Variable function to include/remove those commas after the <<TeachLastName>> and <<Course>> fields.

I tried the attached but not sure if I need to complete it to include ALL the iterations of Teachers/Courses or if I'm completely off.

:banghead: :banghead: :banghead:
A little diddie 'bout black 'n cyan...two reflective colors doin' the best they can.

DCurry

I've never used XMPie so I won't be much help with the nuts and bolts, but maybe can help with the logic. In the data, is 1 always populated, and if there are 2 teacher/courses, is it always going to be 1 and 2, or will it be random like possibly 3 and 6?

I use SmartStream and it has an easy way for me to tell it that if the variables are empty to not include any static copy on that line (like commas.)
Prinect • Signa Station • XMPie

Build a man a fire, and he'll be warm for a night. But set a man on fire, and he'll be warm for the rest of his life!

scottrsimons

I've never used XMPie either, but I use FusionPro and have used SmartStream at times along with GREP in InDesign. And I would write it so it places the ',' when the <<grade>> field is "TRUE" and another rule for when the <<COURSE_>> fields are "TRUE" too. And you may need to write a rule/equation for each of the 6 variables. Might take some time, but should be easy.
"Your superior intellect is no match for our puny weapons!" - Homer J. Simpson

DCurry

I'm thinking even simpler - if we can assume that if <TeachFirstName1 TeachLastName1> is populated then <Course1> and <Grade> are also populated, you could make 6 rules for the comma, but reuse each one twice in each line.
The comma rule would read that if <TeachFirstName1 TeachLastName1> is populated then return a comma. New rule for each line but you only need to consider if ONE of that line's fields is populated because if one is populate, they all should be.

Kinda like this:
<<TeachFirstName_1>> <<TeachLastName_1>><<commaRule1>> <<COURSE_1>><<commaRule1>> <<grade>>
<<TeachFirstName_2>> <<TeachLastName_2>><commaRule2>> <<COURSE_2>><commaRule2>> <<grade>>
<<TeachFirstName_3>> <<TeachLastName_3>><commaRule3>> <<COURSE_2>><commaRule3>> <<grade>>
Prinect • Signa Station • XMPie

Build a man a fire, and he'll be warm for a night. But set a man on fire, and he'll be warm for the rest of his life!

pspdfppdfxhd

Oh, this type of thing used to drive me nuts when it came up.

We had to get DesignMerge to handle this type of situation. I have not done one in a long time but it was, if i remember, simply adding a comma suffix to the variable then if other conditons were not met than deleting the whole thing. Something like that.


Slappy

Quote from: DCurry on January 05, 2021, 07:20:32 AM
I'm thinking even simpler - if we can assume that if <TeachFirstName1 TeachLastName1> is populated then <Course1> and <Grade> are also populated, you could make 6 rules for the comma, but reuse each one twice in each line.
The comma rule would read that if <TeachFirstName1 TeachLastName1> is populated then return a comma. New rule for each line but you only need to consider if ONE of that line's fields is populated because if one is populate, they all should be.

Kinda like this:
<<TeachFirstName_1>> <<TeachLastName_1>><<commaRule1>> <<COURSE_1>><<commaRule1>> <<grade>>
<<TeachFirstName_2>> <<TeachLastName_2>><commaRule2>> <<COURSE_2>><commaRule2>> <<grade>>
<<TeachFirstName_3>> <<TeachLastName_3>><commaRule3>> <<COURSE_2>><commaRule3>> <<grade>>

Pretty similar to what Lammy on here gave me, I still get "rogue" commas and data though and I gave up trying to get a clean formula. Passed it off to our in-house Mail Guru and he knocked out the 38,000 records in no time.
He ended up adding the comma as its own field, by sorting the records that only needed it, pretty crafty & not something I would have tried with a data set this long.
A little diddie 'bout black 'n cyan...two reflective colors doin' the best they can.