Getting formatted data into a global variable

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
Robert [ Do, 10 Januar 2008 05:37 ] [ ID #1904504 ]

Re: Getting formatted data into a global variable

On Jan 9, 9:37 pm, Robert <rmsut... [at] mindspring.com> 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)
Grip [ Do, 10 Januar 2008 16:00 ] [ ID #1904511 ]

Re: Getting formatted data into a global variable

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
Robert [ Do, 10 Januar 2008 16:34 ] [ ID #1904515 ]

Re: Getting formatted data into a global variable

On Jan 10, 8:34 am, Robert <rmsut... [at] mindspring.com> 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.
Grip [ Do, 10 Januar 2008 20:00 ] [ ID #1904523 ]

Re: Getting formatted data into a global variable

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
Robert [ Do, 10 Januar 2008 21:18 ] [ ID #1904525 ]

Re: Getting formatted data into a global variable

On Jan 10, 1:18 pm, Robert <rmsut... [at] mindspring.com> 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
Grip [ Do, 10 Januar 2008 22:20 ] [ ID #1904527 ]

Re: Getting formatted data into a global variable

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?
Chris Brown [ Do, 10 Januar 2008 23:36 ] [ ID #1904530 ]

Re: Getting formatted data into a global variable

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
>
Robert [ Do, 10 Januar 2008 23:45 ] [ ID #1904532 ]

Re: Getting formatted data into a global variable

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.
Robert [ Do, 10 Januar 2008 23:58 ] [ ID #1904533 ]
Datenbanken » comp.databases.filemaker » Getting formatted data into a global variable

Vorheriges Thema: multiple dropdown choice?
Nächstes Thema: what else to get in version 9?