In article <1169586785.761259.98640 (AT) h3g2000cwc (DOT) googlegroups.com>,
"DavidR" <davidcroth (AT) gmail (DOT) com> wrote:
Quote:
Hi:
I have made a calc field with 4 repetitions. I am trying to figure out
how I write the calcuation to calculate all 4 repetitions.
EX: Calc Field Name is PDFName with 4 Reps.
In the Calculation window I can write a calc to enter a result in the
first repetition but not the other 3.
Calc is: PDFName = Purchase Order ID & ".pdf" (Making a name for a
PDF file that is the Purchase Order Number (dot) pdf
I want to make the calc field contain the same name but add a revision
to the end of the Purchase order and before (dot) pdf so the calc field
contains these values:
Rep [1] = PO-00001.pdf
Rep [2] = PO-00001-R2.pdf
Rep [3] = PO-00001-R3.pdf
Rep [4] = PO-00001-R4.pdf
The calcs for the repetitions are easy enough at:
PDFName = Purchase Order ID & ".pdf"
PDFName [2] = Purchase Order ID & "-R2" & ".pdf"
PDFName [3] = Purchase Order ID & "-R3" & ".pdf"
PDFName [4] = Purchase Order ID & "-R4" & ".pdf"
How to I write this out in one Calc window so it calcs a PDF name in
each repetition. |
You're probably better to not use Repeating fields - they tend to be
difficult to use for anything except strictly storing data and are
really just a left-over from the pre-relationship days of FileMaker
Pro.
Depending on what else you need to do with the data in this field, you
might be best to use either separate fields (Filename1, Filename2,
etc.) or a related table ... or even just a Text field with a
calculation to have all the filenames separated by Return characters.
eg.
PartFilenames Calculation, Text Result
= If (NumParts >= 1, BaseFilename & ".pdf")
& If (NumParts >= 2, "¶" & BaseFilename & "-R2.pdf")
& If (NumParts >= 3, "¶" & BaseFilename & "-R3.pdf")
& If (NumParts >= 4, "¶" & BaseFilename & "-R4.pdf")
& If (NumParts = 5, "¶" & BaseFilename & "-R5.pdf")
Where the fields are:
BaseFilename Text {stores the filename without sufixes)
NumParts Number {stores the number of parts for the file}
If you later need more than five Repetitions then you just need to add
another line to this Calculation.
Having said that, if you still really want to having calculating
repetitions then it is technically possible by utilising the Extend
function and a bit of background hocus-pocus.
First though you need to create a Global field (number type) with the
same number of repetitions as your Filename Repeating field.
eg.
g_Index Global, Number, 5 Repetitions
Put this field onto any layout temporarily and in Browse mode type in
the number for each corresponding repetition.
ie.
1
2
3
4
5
Now you will need the Calculation field to store the repetitions of
each part's filename.
eg.
PartFilenames Calculation, Text Result, 5 Repetitions
= If(g_Index <= Extend(NumParts),
Extend(BaseFilename) & "-R" & g_Index & ".pdf",
"")
using the same BaseFilename and NumParts fields as above.
The Extend function allows you to stretch non-repeating fields so that
calculations are performed for all the repetitions of the Repeating
field, not just the first one. This means the calculation basically
says:
If RepetitionNumber (stored in g_Index) is less than or
equal to the NumParts, then set that repetition of
PartFilenames appropriately, otherwise leave that
repetition blank
ie. With 3 typed into NumParts you would get the
field calculating as:
1 <= 3 Yes: "Filename-R1.pdf"
2 <= 3 Yes: "Filename-R2.pdf"
3 <= 3 Yes: "Filename-R3.pdf"
4 <= 3 No: ""
5 <= 3 No: ""
If you later need more than five Repetitions, then you need to remember
increase the number of Repetitions for both PartFilename and Index, as
well as typing in the extra numbers in the Index repetitions.
There is one obvious hiccup here. The filename for the first part will
have the suffix "-R1.pdf". There's not really anything you can do about
this since you're trying to create a single calculation for two
different results - one without the suffix and the rest with it. You
could get around this by having the first part's filename as a separate
Calculation field, and then increasing the values in g_Index by one so
that it starts at "2" for the second part's filename.
Helpful Harry
Hopefully helping harassed humans happily handle handiwork hardships ;o)