Getting formatted data into a global variable
Getting formatted data into a global variable
am 10.01.2008 05:37:21 von Robert
Hello,
I have a number field on a layout whose display is formatted as
currency. I am trying to copy it to a global variable as text retaining
the currency format. Is this possible or have I missed some obvious
function to do this?
Thanks,
Robert Sutton
Re: Getting formatted data into a global variable
am 10.01.2008 16:00:57 von Grip
On Jan 9, 9:37 pm, Robert wrote:
> Hello,
>
> I have a number field on a layout whose display is formatted as
> currency. I am trying to copy it to a global variable as text retaining
> the currency format. Is this possible or have I missed some obvious
> function to do this?
>
Short answer: Why?
Filemaker stores data, layouts format that data. You could format the
number to text adding the $,. where appropriate and store that instead
using a calculation, but why? A user, the person who interacts with
the data, never interacts with a global variable. What are you doing
with a variable that you think you need it formatted?
The actual formula would depend on how big the numbers might be, and
how you want the number formatted (European or US style or other,
commas? etc)
Re: Getting formatted data into a global variable
am 10.01.2008 16:34:49 von Robert
Grip wrote:
> Short answer: Why?
> Filemaker stores data, layouts format that data. You could format the
> number to text adding the $,. where appropriate and store that instead
> using a calculation, but why? A user, the person who interacts with
> the data, never interacts with a global variable. What are you doing
> with a variable that you think you need it formatted?
I am exporting text to a system that does not support formatting of
numbers. I need to get the amount into a variable to pass to an external
for this purpose.
>
> The actual formula would depend on how big the numbers might be, and
> how you want the number formatted (European or US style or other,
> commas? etc)
I was hoping that I wouldn't have to create a complex script to do this
but maybe that's the only way out ??
Robert
Re: Getting formatted data into a global variable
am 10.01.2008 20:00:56 von Grip
On Jan 10, 8:34 am, Robert wrote:
> Grip wrote:
> > Short answer: Why?
> > Filemaker stores data, layouts format that data. You could format the
> > number to text adding the $,. where appropriate and store that instead
> > using a calculation, but why? A user, the person who interacts with
> > the data, never interacts with a global variable. What are you doing
> > with a variable that you think you need it formatted?
>
> I am exporting text to a system that does not support formatting of
> numbers. I need to get the amount into a variable to pass to an external
> for this purpose.
>
>
>
> > The actual formula would depend on how big the numbers might be, and
> > how you want the number formatted (European or US style or other,
> > commas? etc)
>
> I was hoping that I wouldn't have to create a complex script to do this
> but maybe that's the only way out ??
>
> Robert
You don't need a complex script, you need a calculation, one that
would probably involve 5 or 6 functions (namely Let(), Case(),
Right(), Truncate() and Length() ) though it's hard to say because you
don't say what version of FM you're using and what formatting you want.
Re: Getting formatted data into a global variable
am 10.01.2008 21:18:06 von Robert
Grip wrote:
> You don't need a complex script, you need a calculation, one that
> would probably involve 5 or 6 functions (namely Let(), Case(),
> Right(), Truncate() and Length() ) though it's hard to say because you
> don't say what version of FM you're using and what formatting you want.
That's good to hear. I'm using FM Pro 8 Advanced. I just need the usual(
$ , for thousands . and 2 decimal places). If you can point me to a
reference for the calculation I would appreciate it.
Robert
Re: Getting formatted data into a global variable
am 10.01.2008 22:20:24 von Grip
On Jan 10, 1:18 pm, Robert wrote:
> Grip wrote:
> > You don't need a complex script, you need a calculation, one that
> > would probably involve 5 or 6 functions (namely Let(), Case(),
> > Right(), Truncate() and Length() ) though it's hard to say because you
> > don't say what version of FM you're using and what formatting you want.
>
> That's good to hear. I'm using FM Pro 8 Advanced. I just need the usual(
> $ , for thousands . and 2 decimal places). If you can point me to a
> reference for the calculation I would appreciate it.
>
> Robert
Try...
Let([
//number is a number field
integers = Int( number );
decimals = "." & Left( GetAsText( ((number - integers) * 100) & 0) ;
2 );
thousands = Case( Length(integers) > 3; Left(integers;
Length(integers) -3) & "," );
hundreds = Right(integers; 3)
];
"$" & thousands & hundreds & decimals
)
This assumes the totals are two decimals places or less, it doesn't
round up if the number is 23.496 for instance.
needComma = digits > 3;
Case(needComma; left(integers; digi
Re: Getting formatted data into a global variable
am 10.01.2008 23:36:46 von Chris Brown
Robert wrote:
> Hello,
>
> I have a number field on a layout whose display is formatted as
> currency. I am trying to copy it to a global variable as text retaining
> the currency format. Is this possible or have I missed some obvious
> function to do this?
>
> Thanks,
>
> Robert Sutton
or push it to aglobal?
Re: Getting formatted data into a global variable
am 10.01.2008 23:45:57 von Robert
Grip,
Thanks for going above and beyond the call of duty,
Robert
Grip wrote:
>
> Try...
>
> Let([
> //number is a number field
> integers = Int( number );
> decimals = "." & Left( GetAsText( ((number - integers) * 100) & 0) ;
> 2 );
> thousands = Case( Length(integers) > 3; Left(integers;
> Length(integers) -3) & "," );
> hundreds = Right(integers; 3)
> ];
> "$" & thousands & hundreds & decimals
> )
>
> This assumes the totals are two decimals places or less, it doesn't
> round up if the number is 23.496 for instance.
>
>
> needComma = digits > 3;
> Case(needComma; left(integers; digi
>
Re: Getting formatted data into a global variable
am 10.01.2008 23:58:18 von Robert
Chris Brown wrote:
> Robert wrote:
>
>> Hello,
>>
>> I have a number field on a layout whose display is formatted as
>> currency. I am trying to copy it to a global variable as text
>> retaining the currency format. Is this possible or have I missed some
>> obvious function to do this?
>>
>> Thanks,
>>
>> Robert Sutton
>
>
> or push it to aglobal?
I am exporting text to a system that does not support formatting of
numbers. I need to get the amount into a (text) variable to pass to an
external for this purpose.