"how can 6 > 10 yield TRUE"
That is true when you didn't declare the $var as a number; Filemaker ALWAYS interpret an $var as TEXT.
Try to set the $var = GetAsNumber ( YourNumber )
"Filemaker ALWAYS interpret an $var as TEXT"
Thanks for the reply - I have many other scripts with $vars that don't treat the number as a text - should I use the GetAsValue on all $vars to be sure they are numbers?
$var = 1 is a text but, as said, $var = GetAsNumber ( $var ) is a number.
The variable is also a number when it is calculated using an aritmetic operator like:
$var = $var + 1
$var = 1*1
$var = 1+0
or when it is calculated with a numeric function like:
$var = Max ( 1 ; 2 ; 3 )
Rich: there is no function "GetAsValue".
Existing functions include GetAsNumber; GetAsDate; GetAsText; etc.
See relevant section here:
the only difference I could find in my scripts (i.e. comparing the one that treated as text vs the others that treated as number) is that with the $var that was text came directly from a user input box directly into the script. All others were either sourced from a table (with numeric validation etc) or if it came from an input box, it was 'saved' to the field first, went thru some sort of validation scripts, and then assigned to the $var - this MAY explain the difference....
Thanks for all your input!
yep my mistake in the GetAsNumber reply ;)
It has not been my experience that FileMaker always treats a $Var as text. It can depend on how the $Var is assigned a value.
As an example, this expression:
let ( [$Var1 = 2 ; $Var2 = "2" ] ;
list (10 > $Var1 ; 10 > $Var2 )
Yields two return separated values of 1, 0. Which means that 10 > $Var1 evaluates as true, but 10 > $Var2 evaluates as false.
A script using set variable to set $var1 to 2 and $var2 to "2" yields identical results.
Thus, you may want to take a look at how your variable is assigned a value.
"It has not been my experience that FileMaker always treats a $Var as text"
Your example confirms what I said
On the contrary. In my examples, $Var1 is treated as a number and $Var2 is treated as text. Thus a $Var is not always treated as text.
I do not know why your example works... it never worked for me before today.
From Filemaker Help:
• Variables are only supported in script steps that use stored file paths.
• Variables are not supported in file paths that are stored in container fields.
• Variables are not supported in FileMaker data source references.
• The data type of a variable is determined dynamically based on the assigned data. The default data type is text.
But look at the sentence in red--which explains why my example works:
The data type of a variable is determined dynamically based on the assigned data. The default data type is text.
When I use 2 as my value to assign to a variable, it's a number data type. When I use "2" it's text. This is exactly in agreement with the documentation that you quote.
This is yet another example of how FileMaker handles data typing in a dangerously "loose" fashion. It isn't always obvious what data type will be assigned when the variable was created with a set field script step or Let function call.
I would much prefer variables that have to have a data type explicitly specified before they can have a value assigned.
However, I am convinced that there must have been some change in how it behaves the $var in the latest versions.
I have to go and try your calculation on 9.