|
Best of Support |
|
|
Punctuating paragraphs |
|
Issue
How to punctuate a series of conditional paragraphs.
Solution:
How often do you have a string of paragraphs or sub-clauses in a series where, e.g., Clause B, Clause F and Clause G are conditional, and you need to make sure you have the proper punctuation and conjunctives?
The approach below creates a block called "Para" which puts in the proper punctuation string:
%[SetBlock('Para')]%[PCounter = (PCounter + 1) |Increment the counter]%[IfTrue((PCounter = PCount), PFinal, IfTrue((PCounter = (PCount - 1)), (PMark & PConj), PMark))
|Determine Proper Punctuation for last entry, second to last entry and all preceding entries]%[EndBlock()]
PMark = Standard punctuation at end of phrase or paragraph (for example, ",", ";", etc.).
PConj = The conjugator (for example, "and", "or", etc.).
PFinal = Final punctuation.
PCount = The count of paragraphs or clauses in the sequence you are punctuating.
PCounter = An incrementing counter that steps the count with each usage of "Para".
For the Para to work you need to set PMark, PConj, PFinal, PCounter and PCount just before the beginning of the sequence. In setting PCount, you need to mirror the logic in the sequence of paragraphs to get a proper count of paragraphs.
Below is a sample:
%[PCounter = 0 ; PMark = ', ' ; PConj = ' or ' ; PFinal = '.' ; PCount = 2 ; PCount = IfTrue(Condition1, (PCount + 1), PCount) ; PCount = IfTrue(Condition2, (PCount + 1), PCount)
|Initialization String and setting the PCount]
The above sequence assumes there are always 2 paragraphs. And if Condition1 and Condition2 are met there could be a total of four paragraphs.
Enjoy,
Seth Rowland