dbTalk Databases Forums  

Value List technique

comp.databases.filemaker comp.databases.filemaker


Discuss Value List technique in the comp.databases.filemaker forum.



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

Default Value List technique - 01-07-2007 , 04:26 AM






Hi all . I was under the impression that there would be some function
that allowed me to move between an item in a predefined value list, and
it's position in the list. For example, if I had a value list of
months, then I could take the value, and look to find its position in
the list.

This seems to not be an available function, probably because a list can
change at any time and kill you data. And yes, I'm trying to emulate an
'enum'.

It seems that the right thing to do would be to go relational-crazy and
use a table for a value list, and the primary key numbers and values
are fixed. For example, record #1 is 'January;, #2 is 'Feb, etc. Sound
good?


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

Default Re: Value List technique - 01-07-2007 , 05:08 AM






Very good,

and I don't call it relational-crazy, I call it sound practice! It is much
more easy to work on a table then to work on a hardcoded value list. Say
that you would have to translate all those months in a hardcoded list. You
would not only have to change the list itself, but change all the names of
the months you already had entered. Now with a value list in a table (With
proper ID's in place) you would only have to translate the months. Since you
refer to the ID all the references will be updated at once.

Ursus

"Mike" <exceptionsTakeMeOut (AT) earthlink (DOT) net> schreef in bericht
news:2007010705272475249-exceptionsTakeMeOut (AT) earthlinknet (DOT) ..
Quote:
Hi all . I was under the impression that there would be some function that
allowed me to move between an item in a predefined value list, and it's
position in the list. For example, if I had a value list of months, then I
could take the value, and look to find its position in the list.

This seems to not be an available function, probably because a list can
change at any time and kill you data. And yes, I'm trying to emulate an
'enum'.

It seems that the right thing to do would be to go relational-crazy and
use a table for a value list, and the primary key numbers and values are
fixed. For example, record #1 is 'January;, #2 is 'Feb, etc. Sound good?




Reply With Quote
  #3  
Old   
Mike
 
Posts: n/a

Default Re: Value List technique - 01-07-2007 , 02:18 PM



On 2007-01-07 06:08:49 -0500, "Ursus" <ursus.kirk (AT) wanadoo (DOT) nl> said:

Quote:
Very good,

and I don't call it relational-crazy, I call it sound practice! It is
much more easy to work on a table then to work on a hardcoded value
list. Say that you would have to translate all those months in a
hardcoded list. You would not only have to change the list itself, but
change all the names of the months you already had entered. Now with a
value list in a table (With proper ID's in place) you would only have
to translate the months. Since you refer to the ID all the references
will be updated at once.
Thx. It seems to work well and to make sense. What I've done so far is
have the value list use the 'second field' option, so I get

1 jan
2 feb...

and so on. However, this field relates to, stores, and displays the
primary key, so you sort of lose the month name once you make a
selection. I can get the name from the relation, but I'd prefer the
user to see the month by name of course.

I could have the primary key in the Months table be the actual month
name, but that's Bad.


Quote:
Ursus

"Mike" <exceptionsTakeMeOut (AT) earthlink (DOT) net> schreef in bericht
news:2007010705272475249-exceptionsTakeMeOut (AT) earthlinknet (DOT) ..
Hi all . I was under the impression that there would be some function
that allowed me to move between an item in a predefined value list, and
it's position in the list. For example, if I had a value list of
months, then I could take the value, and look to find its position in
the list.

This seems to not be an available function, probably because a list can
change at any time and kill you data. And yes, I'm trying to emulate an
'enum'.

It seems that the right thing to do would be to go relational-crazy and
use a table for a value list, and the primary key numbers and values
are fixed. For example, record #1 is 'January;, #2 is 'Feb, etc. Sound
good?



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

Default Re: Value List technique - 01-07-2007 , 04:37 PM



What I have done in the past is making the selection field as small as is
practical, then dragged the related field nex to it (and locked it). So when
the user chooses and tabs out his choise is permanently displayed.

Ursus


"Mike" <exceptionsTakeMeOut (AT) earthlink (DOT) net> schreef in bericht
news:2007010715201350073-exceptionsTakeMeOut (AT) earthlinknet (DOT) ..
Quote:
On 2007-01-07 06:08:49 -0500, "Ursus" <ursus.kirk (AT) wanadoo (DOT) nl> said:

Very good,

and I don't call it relational-crazy, I call it sound practice! It is
much more easy to work on a table then to work on a hardcoded value list.
Say that you would have to translate all those months in a hardcoded
list. You would not only have to change the list itself, but change all
the names of the months you already had entered. Now with a value list in
a table (With proper ID's in place) you would only have to translate the
months. Since you refer to the ID all the references will be updated at
once.

Thx. It seems to work well and to make sense. What I've done so far is
have the value list use the 'second field' option, so I get

1 jan
2 feb...

and so on. However, this field relates to, stores, and displays the
primary key, so you sort of lose the month name once you make a selection.
I can get the name from the relation, but I'd prefer the user to see the
month by name of course.

I could have the primary key in the Months table be the actual month name,
but that's Bad.



Ursus

"Mike" <exceptionsTakeMeOut (AT) earthlink (DOT) net> schreef in bericht
news:2007010705272475249-exceptionsTakeMeOut (AT) earthlinknet (DOT) ..
Hi all . I was under the impression that there would be some function
that allowed me to move between an item in a predefined value list, and
it's position in the list. For example, if I had a value list of months,
then I could take the value, and look to find its position in the list.

This seems to not be an available function, probably because a list can
change at any time and kill you data. And yes, I'm trying to emulate an
'enum'.

It seems that the right thing to do would be to go relational-crazy and
use a table for a value list, and the primary key numbers and values are
fixed. For example, record #1 is 'January;, #2 is 'Feb, etc. Sound good?





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

Default Re: Value List technique - 01-07-2007 , 05:40 PM



In article <2007010705272475249-exceptionsTakeMeOut@earthlinknet>, Mike
<exceptionsTakeMeOut (AT) earthlink (DOT) net> wrote:

Quote:
Hi all . I was under the impression that there would be some function
that allowed me to move between an item in a predefined value list, and
it's position in the list. For example, if I had a value list of
months, then I could take the value, and look to find its position in
the list.

This seems to not be an available function, probably because a list can
change at any time and kill you data. And yes, I'm trying to emulate an
'enum'.

It seems that the right thing to do would be to go relational-crazy and
use a table for a value list, and the primary key numbers and values
are fixed. For example, record #1 is 'January;, #2 is 'Feb, etc. Sound
good?
It depends on what you're trying to do and how the Value List works.

A separate Table / File to contain the values for the Value List can be
one method, and is especially useful if you need to let novice users
alter the list values.

If all you need to do is convert a value to the number of it's position
in a Value List, then there is another way ... assuming that you're
only allowing one value from the Value List in the data field (ie. a
pop-up list, menu or radio buttons), not using a multi-value field (ie.
checkboxes).

The first and most obvious method is to simply hard-code the values
into a pile of If statements or more senisbly one Case statement. (I've
never heard of "enum", but I've called the new field that.)
eg.
enum = Case (Field = "January", 1,
Field = "February", 2,
Field = "March", 3,
...
Field = "December", 12,
0)

The problem here is that every time you change the text in the Value
List you also need to remember to change the hard-coded values in this
calculation so that they match.

You can avoid this problem by using the ValueListItems function to
obtain the text from the Value List itself and the Position function to
separate each line it is (by using the locating Return character before
and after each item).
eg.
ValueListText = ValueListItems("Filename", ValueListName")

"Filename" is the name of your database file and "ValueListName" is the
name of the Value List that you have defined.

enum = Case (Field = Left(ValueListText, Position(ValueListText,
"¶", 1, 1) - 1), 1,
Field = Middle(ValueListText, Position(ValueListText,
"¶", 1, 1) + 1, Position(ValueListText, "¶",
1, 2) - Position(ValueListText, "¶", 1, 1)
- 1), 2,
Field = Middle(ValueListText, Position(ValueListText,
"¶", 1, 2) + 1, Position(ValueListText, "¶",
1, 3) - Position(ValueListText, "¶", 1, 2)
- 1), 3,
...
Field = Middle(ValueListText, Position(ValueListText,
"¶", 1, X-1) + 1, Position(ValueListText, "¶",
1, X) - Position(ValueListText, "¶", 1, X-1)
- 1), X,
0)

Where X (in the last line) is the number of Value List item. I've only
used a new Calculation field called ValueListText to simplify the enum
calculation - you can simply replace all the ValueListText field names
in enum with ValueListItems("Filename", ValueListName").

This is fine as long as you're only changing existing Value List items,
but if you add a new one then you'll have to remember to add another
line to this calculation. Removing a Value List item shouldn't cause a
problem.

You can probably get around this by using the Custom Functions ability
in newer versions of FileMaker to make a looping function something
along the lines of this pseudo-code (sorry, I don't know how the Custom
Functions work):

X = PatternCount(ValueListText, {Return Char}) + 2
ValueListText = ValueListItems("Filename", ValueListName")

Loop
X = X - 1
Until
(X = 0) or (Field = Middle(ValueListText, Position(ValueListText,
"¶", 1, X-1) + 1, Position(ValueListText,
"¶", 1, X) - Position(ValueListText, "¶", 1,
X-1) - 1))

enum = X

Another way would be to use a looping function like this to keep
removing the top item from ValueListText and comparing it to Field,
stopping when either a match is found or the ValueListText becomes an
empty field.



Note: All of the above calculations return a 0 value if the data in
Field doesn't actually appear in the Value List. This makes it easier
to find records with problems after altering the Value List (as long as
the calculation is not stored).





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


Reply With Quote
  #6  
Old   
Mike
 
Posts: n/a

Default Re: Value List technique - 01-08-2007 , 09:07 AM



On 2007-01-07 17:37:10 -0500, "Ursus" <ursus.kirk (AT) wanadoo (DOT) nl> said:

Quote:
What I have done in the past is making the selection field as small as
is practical, then dragged the related field nex to it (and locked it).
So when the user chooses and tabs out his choise is permanently
displayed.

Ursus

Sneaky, I like it. Thx.



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.