dbTalk Databases Forums  

Containers in calculations

comp.databases.filemaker comp.databases.filemaker


Discuss Containers in calculations in the comp.databases.filemaker forum.



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

Default Containers in calculations - 11-11-2006 , 01:20 AM






Suppose you have a table called ShapeTable with a name field called
Shape Name and a container field called Shape, and another table with a
field Shapes that takes up to two Shape Names (say that it is a
repeating field, but it could very well be two fields, a multi-key
field, or some other form). I want to make a calculation that returns
a container containing their corresponding shapes (so if I have entered
"Square/Circle", then I get a square and a circle in the one
container).

Problem is that FM doesn't seem to do that AFAIK, and the best I can
hope for is a repeating field of two containers. Yet, I get this
problem with "Square/Circle": if my two shape names are entered in
repeating fields, and I specify my calculation as ShapeTable::Shape, I
get a square in one and nothing in the other, yet if I have
Extend(ShapeTable::Shape), I get either squares in both or circles in
both. So how do I make it so that I have a square in one and a circle
in the other?

--
I am only a mirage.

Reply With Quote
  #2  
Old   
Hans
 
Posts: n/a

Default Re: Containers in calculations - 11-11-2006 , 06:36 PM






kelvSYC <kelvSYC (AT) no (DOT) email.shaw.ca> wrote:
Quote:
Problem is that FM doesn't seem to do that AFAIK, and the best I can
hope for is a repeating field of two containers. Yet, I get this
problem with "Square/Circle": if my two shape names are entered in
repeating fields, and I specify my calculation as ShapeTable::Shape, I
get a square in one and nothing in the other, yet if I have
Extend(ShapeTable::Shape), I get either squares in both or circles in
both. So how do I make it so that I have a square in one and a circle
in the other?
You may lookup values into a repeating field. Other relational functions
don't work on repeating fields.


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

Default Re: Containers in calculations - 11-11-2006 , 07:58 PM



In article <111120060020304828%kelvSYC (AT) no (DOT) email.shaw.ca>, kelvSYC
<kelvSYC (AT) no (DOT) email.shaw.ca> wrote:

Quote:
Suppose you have a table called ShapeTable with a name field called
Shape Name and a container field called Shape, and another table with a
field Shapes that takes up to two Shape Names (say that it is a
repeating field, but it could very well be two fields, a multi-key
field, or some other form). I want to make a calculation that returns
a container containing their corresponding shapes (so if I have entered
"Square/Circle", then I get a square and a circle in the one
container).

Problem is that FM doesn't seem to do that AFAIK, and the best I can
hope for is a repeating field of two containers. Yet, I get this
problem with "Square/Circle": if my two shape names are entered in
repeating fields, and I specify my calculation as ShapeTable::Shape, I
get a square in one and nothing in the other, yet if I have
Extend(ShapeTable::Shape), I get either squares in both or circles in
both. So how do I make it so that I have a square in one and a circle
in the other?
Obviously you can't have two shapes in a single Container field and
Repeating fields are usually more a pain in the "sit-upon" than
actually useful.

You'd be best to use two separate sets of fields. Then you can type
"Square" into one field and a square appears in the first Container
field, and type "Circle" into a second field and have a circle appear
in the second field.



Helpful Harry
Hopefully helping harassed humans happily handle handiwork hardships ;o)


Reply With Quote
  #4  
Old   
kelvSYC
 
Posts: n/a

Default Re: Containers in calculations - 11-11-2006 , 10:53 PM



Quote:
You'd be best to use two separate sets of fields. Then you can type
"Square" into one field and a square appears in the first Container
field, and type "Circle" into a second field and have a circle appear
in the second field.
Well, it is an obvious solution. However, I also need to encapsulate
the information that you could have up to two shapes, so I need
something that accomodates "Square" and "Square/Circle". These need to
be ordered for presentation purposes (so if I enter "Square/Circle" and
"Circle/Square", they would be presented in that order) but is not
needed for the internals (ie. FM would consider "Square/Circle" and
"Circle/Square" be the same).

I've also tried multi-keys, but the ShapeTable::Shape only returns the
first shape. (ie. the square if "Square/Circle" is entered)

I've tried to avoid having a separate table, but it may be the case
that I have to resort to doing that.

--
I am only a mirage.


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

Default Re: Containers in calculations - 11-12-2006 , 12:18 AM



In article <111120062153390229%kelvSYC (AT) no (DOT) email.shaw.ca>, kelvSYC
<kelvSYC (AT) no (DOT) email.shaw.ca> wrote:

Quote:
You'd be best to use two separate sets of fields. Then you can type
"Square" into one field and a square appears in the first Container
field, and type "Circle" into a second field and have a circle appear
in the second field.

Well, it is an obvious solution. However, I also need to encapsulate
the information that you could have up to two shapes, so I need
something that accomodates "Square" and "Square/Circle". These need to
be ordered for presentation purposes (so if I enter "Square/Circle" and
"Circle/Square", they would be presented in that order) but is not
needed for the internals (ie. FM would consider "Square/Circle" and
"Circle/Square" be the same).

I've also tried multi-keys, but the ShapeTable::Shape only returns the
first shape. (ie. the square if "Square/Circle" is entered)

I've tried to avoid having a separate table, but it may be the case
that I have to resort to doing that.
As far as I understand it (and maybe I'm missing something essential),
using two fields would easily work for what you're wanting to do.
ie.
Shape1 Shape2 Graphic1 Graphic2

Square {empty} square {empty}

Square Circle square circle

Circle Square circle square

Your two shapes are simply entered in two separate fields in the
appropriate order - instead of "Square/Circle" you type in "Square" and
"Circle".

You do of course need two Relationships to the Shapes Table - one using
Shape1 and one using Shape2 as the parent field.

If needed, you can have a third text field that uses a calculation to
combine the two text fields.
ie.
All Shapes {Calculation, Text Result}
= Field1 & If (IsEmpty(Field2), "", "{return}" & Field2)

Perform finds (for example) could then be done on this third field to
easily find all records with "Circle" in either Field 1 or Field 2.

This method is also easy to expand into three, four or more shapes (eg.
perhaps "Square/Circle/Triangle") by simply adding another pair of
fields.


If you really want ot use just one Text field, then you'll need two (or
more) Calculation fields that split up the text by simply searching for
the "/" character, it's then these Calculation fields that are used in
the Relationships to retrieve the appropriate graphic rather than the
original Text field
ie.
Shapes Text

Shape_1 Calculation, Text Result
= if (PatternCount(Shapes, "/", 1,1) = 0,
Shapes,
Left(Shapes, Position(Shapes, "/", 1, 1) - 1)
)

Shape_2 Calculation, Text Result
= if (PatternCount(Shapes, "/", 1,1) = 1,
"",
Right(Shapes, Length(Shapes)
- Position(Shapes, "/", 1, 1) - 1)
)

But this is a more difficult to expand to more shapes.



Helpful Harry
Hopefully helping harassed humans happily handle handiwork hardships ;o)


Reply With Quote
  #6  
Old   
Bill Marriott
 
Posts: n/a

Default Re: Containers in calculations - 11-12-2006 , 12:20 AM



I guess it's still "going over my head" what you're trying to do.

You want to enter into one field either

Square
Circle
Square/Circle
Circle/Square
or <empty>

and then you want a container field to do what, exactly, in each situation?

And, is the objective to literally have the result contained within a single
field, or merely to create a certain kind of appearance? And what is the
difference, in appearance, between Square/Circle and Circle/Square?

"kelvSYC" <kelvSYC (AT) no (DOT) email.shaw.ca> wrote

Quote:
You'd be best to use two separate sets of fields. Then you can type
"Square" into one field and a square appears in the first Container
field, and type "Circle" into a second field and have a circle appear
in the second field.

Well, it is an obvious solution. However, I also need to encapsulate
the information that you could have up to two shapes, so I need
something that accomodates "Square" and "Square/Circle". These need to
be ordered for presentation purposes (so if I enter "Square/Circle" and
"Circle/Square", they would be presented in that order) but is not
needed for the internals (ie. FM would consider "Square/Circle" and
"Circle/Square" be the same).

I've also tried multi-keys, but the ShapeTable::Shape only returns the
first shape. (ie. the square if "Square/Circle" is entered)

I've tried to avoid having a separate table, but it may be the case
that I have to resort to doing that.

--
I am only a mirage.



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.