|
Tip>Designer |
|
|
Setting the punctuation in a series of paragraphs or Clauses |
|
|
Article #: |
0046 |
|
Contributor: |
Seth Rowland |
|
GF version: |
4.0 |
|
Applies to: |
Document logic and paragraphs or Clauses |
|
Last updated: |
January 13, 2003 |
Description
You may have a series of paragraphs or Clauses with some of the paragraphs being conditional. If text is to be excluded, you need to make sure you have the proper punctuation and conjunctives (conjunctions) in the end result.
Explanation
You can add script to your template which determines the number of paragraphs or Clauses and inserts the correct punctuation.
Click here to view a step-by-step example.
Create a block called Para which counts the number of paragraphs and inserts the punctuation:
%[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()]
The variables in the above block of script can be defined as follows:
PMark = Standard punctuation at end of phrase or paragraph (e.g.," , " or " ; ", etc.).
PConj = The conjunctive (conjunction) (e.g.," 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 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 script assumes there are always a minimum of two paragraphs (PCount = 2). And if Condition1 and Condition2 are met, there could be a total of four paragraphs.
You then need to insert the FillPoint %[Para] after each paragraph or Clause in the sequence.