dbTalk Databases Forums  

Calc Field with Repetitions - Getting results in repetitions

comp.databases.filemaker comp.databases.filemaker


Discuss Calc Field with Repetitions - Getting results in repetitions in the comp.databases.filemaker forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
DavidR
 
Posts: n/a

Default Calc Field with Repetitions - Getting results in repetitions - 01-23-2007 , 03:13 PM






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.

Thank you
David


Reply With Quote
  #2  
Old   
Helpful Harry
 
Posts: n/a

Default Re: Calc Field with Repetitions - Getting results in repetitions - 01-24-2007 , 11:17 PM






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)


Reply With Quote
  #3  
Old   
Howard Schlossberg
 
Posts: n/a

Default Re: Calc Field with Repetitions - Getting results in repetitions - 01-25-2007 , 10:06 AM



How about:
"12345" &
Case(Get ( CalculationRepetitionNumber ) > 1; "-R" & Get (
CalculationRepetitionNumber )) &
".pdf"


DavidR 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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Howard Schlossberg
FM Professional Solutions, Inc. Los Angeles

FileMaker 8 Certified Developer
Associate Member, FileMaker Solutions Alliance


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.