dbTalk Databases Forums  

Double calculations

comp.databases.filemaker comp.databases.filemaker


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



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

Default Double calculations - 01-07-2007 , 04:42 PM






I have inherited a file. The original creater has a lot of fields like this

Length(GetAsText(GetAsNumber(Start Number))) ? 4

Where Start Number is defined as a number. Why he/she has done this double
getastext/getasnumber is a mystery to me. Is there any reason I can't see
why these are there? Since I don't know who originaly made this I can ask
him.

Ursus



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

Default Re: Double calculations - 01-07-2007 , 05:45 PM






In article <45a17753$0$27166$dbd45001 (AT) news (DOT) wanadoo.nl>, "Ursus"
<ursus.kirk (AT) wanadoo (DOT) nl> wrote:

Quote:
I have inherited a file. The original creater has a lot of fields like this

Length(GetAsText(GetAsNumber(Start Number))) ? 4

Where Start Number is defined as a number. Why he/she has done this double
getastext/getasnumber is a mystery to me. Is there any reason I can't see
why these are there? Since I don't know who originaly made this I can ask
him.
Without seeing the entire database, it looks pointless to me too.
GetAsNumber on a Number field is a waste of time - it's already a
number. \

Depending on what the "?" charcter really is, it may also be a waste of
time changing it to Text to get a length when simply comparing it to a
number will work. If the "?" is really the single form of ">=" then you
can just use
Start Number >= 1000
to make sure there are four or more digits.

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


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

Default Re: Double calculations - 01-07-2007 , 06:30 PM



Helpful Harry wrote:

Quote:
In article <45a17753$0$27166$dbd45001 (AT) news (DOT) wanadoo.nl>, "Ursus"
ursus.kirk (AT) wanadoo (DOT) nl> wrote:


I have inherited a file. The original creater has a lot of fields like this

Length(GetAsText(GetAsNumber(Start Number))) ? 4

Where Start Number is defined as a number. Why he/she has done this double
getastext/getasnumber is a mystery to me. Is there any reason I can't see
why these are there? Since I don't know who originaly made this I can ask
him.


Without seeing the entire database, it looks pointless to me too.
GetAsNumber on a Number field is a waste of time - it's already a
number. \
And Length will return the number of characters in a field whether it's
a text field or a number field.

"Length(GetAsText(GetAsNumber(..." seems pointless. It could just be
"Length(field)"

There must be more going on behind the scenes.

Quote:
Depending on what the "?" charcter really is, it may also be a waste of
time changing it to Text to get a length when simply comparing it to a
number will work. If the "?" is really the single form of ">=" then you
can just use
Start Number >= 1000
to make sure there are four or more digits.
Unless they wish to allow "0" as a leading character, in which case a
Length statement will do nicely.



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

Default Re: Double calculations - 01-09-2007 , 05:52 PM



In article <Jggoh.100$B25.85 (AT) news01 (DOT) roc.ny>, Vandar
<vandar69 (AT) yahoo (DOT) com> wrote:

Quote:
Helpful Harry wrote:

In article <45a17753$0$27166$dbd45001 (AT) news (DOT) wanadoo.nl>, "Ursus"
ursus.kirk (AT) wanadoo (DOT) nl> wrote:


I have inherited a file. The original creater has a lot of fields like this

Length(GetAsText(GetAsNumber(Start Number))) ? 4

Where Start Number is defined as a number. Why he/she has done this double
getastext/getasnumber is a mystery to me. Is there any reason I can't see
why these are there? Since I don't know who originaly made this I can ask
him.


Without seeing the entire database, it looks pointless to me too.
GetAsNumber on a Number field is a waste of time - it's already a
number. \

And Length will return the number of characters in a field whether it's
a text field or a number field.

"Length(GetAsText(GetAsNumber(..." seems pointless. It could just be
"Length(field)"

There must be more going on behind the scenes.
True. You can use many Text functions on Number fields (and vice-versa)
since FileMaker is fairly forgiving about data types. But it's rather
pointless - you may as well simply test against a number rather than
use Length.



Quote:
Depending on what the "?" charcter really is, it may also be a waste of
time changing it to Text to get a length when simply comparing it to a
number will work. If the "?" is really the single form of ">=" then you
can just use
Start Number >= 1000
to make sure there are four or more digits.

Unless they wish to allow "0" as a leading character, in which case a
Length statement will do nicely.
Although you can format a Number field to display leading zeros, they
aren't actually stored, so the Length function on a Number field will
only give the number of actual digits in the number without any leading
zeroes (or trailing zeroes after the decimal point). Because of this
the original over-complicated calculation above won't tell you about
leading zeros.

If you want to utilise leading zeros in any way other than displaying
them, then you have to use a Text field to store your numbers rather
than a Number field ... or every time you want to know you could use a
calculation like:

Right ("00000" & NumberField, RequiredDigits)

Either way you can then use the Length function.

It gets a little more complicated if you want both leading and trailing
zeroes since you have to work out where the decimal point is.


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


Reply With Quote
  #5  
Old   
Vandar
 
Posts: n/a

Default Re: Double calculations - 01-09-2007 , 06:09 PM



Helpful Harry wrote:

Quote:
In article <Jggoh.100$B25.85 (AT) news01 (DOT) roc.ny>, Vandar
vandar69 (AT) yahoo (DOT) com> wrote:


Helpful Harry wrote:


In article <45a17753$0$27166$dbd45001 (AT) news (DOT) wanadoo.nl>, "Ursus"
ursus.kirk (AT) wanadoo (DOT) nl> wrote:



I have inherited a file. The original creater has a lot of fields like this

Length(GetAsText(GetAsNumber(Start Number))) ? 4

Where Start Number is defined as a number. Why he/she has done this double
getastext/getasnumber is a mystery to me. Is there any reason I can't see
why these are there? Since I don't know who originaly made this I can ask
him.


Without seeing the entire database, it looks pointless to me too.
GetAsNumber on a Number field is a waste of time - it's already a
number. \

And Length will return the number of characters in a field whether it's
a text field or a number field.

"Length(GetAsText(GetAsNumber(..." seems pointless. It could just be
"Length(field)"

There must be more going on behind the scenes.


True. You can use many Text functions on Number fields (and vice-versa)
since FileMaker is fairly forgiving about data types. But it's rather
pointless - you may as well simply test against a number rather than
use Length.




Depending on what the "?" charcter really is, it may also be a waste of
time changing it to Text to get a length when simply comparing it to a
number will work. If the "?" is really the single form of ">=" then you
can just use
Start Number >= 1000
to make sure there are four or more digits.

Unless they wish to allow "0" as a leading character, in which case a
Length statement will do nicely.


Although you can format a Number field to display leading zeros, they
aren't actually stored, so the Length function on a Number field will
only give the number of actual digits in the number without any leading
zeroes (or trailing zeroes after the decimal point). Because of this
the original over-complicated calculation above won't tell you about
leading zeros.
I was assuming that leading zeroes were entered into the field, not
included through number formatting.
With number formatting, you are exactly right.
With data entry of leading zeroes, Length will count them. (It will also
count a manually entered decimal point)

Quote:
If you want to utilise leading zeros in any way other than displaying
them, then you have to use a Text field to store your numbers rather
than a Number field ... or every time you want to know you could use a
calculation like:

Right ("00000" & NumberField, RequiredDigits)

Either way you can then use the Length function.

It gets a little more complicated if you want both leading and trailing
zeroes since you have to work out where the decimal point is.


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

Default Re: Double calculations - 01-09-2007 , 11:17 PM



In article <P8Woh.255$B25.18 (AT) news01 (DOT) roc.ny>, Vandar
<vandar69 (AT) yahoo (DOT) com> wrote:

Quote:
Helpful Harry wrote:

In article <Jggoh.100$B25.85 (AT) news01 (DOT) roc.ny>, Vandar
vandar69 (AT) yahoo (DOT) com> wrote:


Helpful Harry wrote:

Depending on what the "?" charcter really is, it may also be a waste of
time changing it to Text to get a length when simply comparing it to a
number will work. If the "?" is really the single form of ">=" then you
can just use
Start Number >= 1000
to make sure there are four or more digits.

Unless they wish to allow "0" as a leading character, in which case a
Length statement will do nicely.


Although you can format a Number field to display leading zeros, they
aren't actually stored, so the Length function on a Number field will
only give the number of actual digits in the number without any leading
zeroes (or trailing zeroes after the decimal point). Because of this
the original over-complicated calculation above won't tell you about
leading zeros.

I was assuming that leading zeroes were entered into the field, not
included through number formatting.
With number formatting, you are exactly right.
With data entry of leading zeroes, Length will count them. (It will also
count a manually entered decimal point)
A quick test proves we're both wrong. )

A Number field left to a display format of "General" does display
leading zeros typed into it (and therefore I was wrong since it must
also store them), but they are not counted by the Length function.

NumField = 05 Length(NumField) = 1
TxtField = "05" Length(TxtField) = 2

Trailing zeros are ignored, as is the decimal point itself.

NumField = 5.0 Length(NumField) = 1
TxtField = "5.0" Length(TxtField) = 4

NumField = 05.05 Length(NumField) = 4
TxtField = "05.05" Length(TxtField) = 5


Note: The test was done in FileMaker 5.5 which is the newest version on
this particular Mac. This behaviour may be a bug that since been fixed
in newer versions.


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


Reply With Quote
  #7  
Old   
Vandar
 
Posts: n/a

Default Re: Double calculations - 01-10-2007 , 07:09 AM



Helpful Harry wrote:
Quote:
In article <P8Woh.255$B25.18 (AT) news01 (DOT) roc.ny>, Vandar
vandar69 (AT) yahoo (DOT) com> wrote:


Helpful Harry wrote:


In article <Jggoh.100$B25.85 (AT) news01 (DOT) roc.ny>, Vandar
vandar69 (AT) yahoo (DOT) com> wrote:



Helpful Harry wrote:


Depending on what the "?" charcter really is, it may also be a waste of
time changing it to Text to get a length when simply comparing it to a
number will work. If the "?" is really the single form of ">=" then you
can just use
Start Number >= 1000
to make sure there are four or more digits.

Unless they wish to allow "0" as a leading character, in which case a
Length statement will do nicely.


Although you can format a Number field to display leading zeros, they
aren't actually stored, so the Length function on a Number field will
only give the number of actual digits in the number without any leading
zeroes (or trailing zeroes after the decimal point). Because of this
the original over-complicated calculation above won't tell you about
leading zeros.

I was assuming that leading zeroes were entered into the field, not
included through number formatting.
With number formatting, you are exactly right.
With data entry of leading zeroes, Length will count them. (It will also
count a manually entered decimal point)


A quick test proves we're both wrong. )

A Number field left to a display format of "General" does display
leading zeros typed into it (and therefore I was wrong since it must
also store them), but they are not counted by the Length function.

NumField = 05 Length(NumField) = 1
TxtField = "05" Length(TxtField) = 2

Trailing zeros are ignored, as is the decimal point itself.

NumField = 5.0 Length(NumField) = 1
TxtField = "5.0" Length(TxtField) = 4

NumField = 05.05 Length(NumField) = 4
TxtField = "05.05" Length(TxtField) = 5


Note: The test was done in FileMaker 5.5 which is the newest version on
this particular Mac. This behaviour may be a bug that since been fixed
in newer versions.
I didn't think to try it in 5.5.
Here are results for the same test in 8.5 Advanced. (quotation marks and
decimal points are counted)

NumField = 05 Length(NumField) = 2
TxtField = "05" Length(TxtField) = 4
NumField = 5.0 Length(NumField) = 3
TxtField = "5.0" Length(TxtField) = 5
NumField = 05.05 Length(NumField) = 5
TxtField = "05.05" Length(TxtField) = 7



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.