Combining fields and formatting result

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Combining fields and formatting result

Tas Karas
I'm a FileMaker newbie, and found this method of combining two separate
fields into one.



Substitute (List(Field_1, Field_2, Field_3, etc); "¶", " ")




Just wondering whether it is possible to format elements of the final
combination.


For example, one of my fields is *volume *and the other is *issue*.  Each
of these fields contains a number.  In the example below, 15 is the volume,
and 4 is the issue.



Can I create a combination where the contents of the combined field that
looks like the example below, that is, the volume number is formatted as
bold, and the issue number appears in brackets?


* 15*(4)


Also, can I combine to number fields so that the combination is separated
by a dash, for example:


345-350








Thanks!
_______________________________________________
FMPexperts mailing list
[hidden email]
http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Combining fields and formatting result

John Weinshel
You'll notice this list does not respect formatted text, so we can't see
any bolding, etc.

You can do whatever you like to each element. Be aware, though, that
creating field definitions from these kinds of calculations will work, but
it's not usually the most economical approach. Better if you can use
scripts to apply the same logic to set some value to the same calculation.

But if you are new to Filemaker and not yet comfortable with scripting, go
ahead and build the calcs you need.

The basic idea is as follows:

List(
   some_operation(Field_1);
   another_operation(field_2);
   leave_me_alone(field_3);
   some_more_stuff(field4);
)

...where each line ends in a semi-colon. That will return a list, and
you'll need to substitute out the returns to get a single line string,
similar to what you have already worked out.*


The made-up functions wrapping the fields could be text formatting, i.e.:

TextStyleAdd(field_4; bold)

...or an arithmetic operation:

(field_3*field_4)

...or concatenated text:

"foobar " & field_5

... or:

"(" & field_5 & ")"

If you just want the field value in the list, don't wrap it in anything:

List(
   some_operation(Field_1);
   another_operation(field_2);
   field_3;
   some_more_stuff(field4);
)


If arithmetic operations break because they are treating the fields as
text, you can use GetAsNumber(your_field) to ensure the data type.

Conversely, take care in your last example ('345-350') that 350 is not
subtracted from 345. You can use double quotes or GetAsText() to coerce
where needed.

Good luck.

John Weinshel
Datagrace, LLC



*You can use Substitute() again, against the entire expression. Easier to
read is a Let() statement:

Let(
  [
   my_expression =
     List(
     some_operation(Field_1);
     another_operation(field_2);
     leave_me_alone(field_3);
     some_more_stuff(field4);
     );

   result = Substitute(my_expression; "¶"; "")
  ];
result
)







On 6/7/17, 6:47 PM, "Tas Karas" <[hidden email]> wrote:

>I'm a FileMaker newbie, and found this method of combining two separate
>fields into one.
>
>
>
>Substitute (List(Field_1, Field_2, Field_3, etc); "¶", " ")
>
>
>
>
>Just wondering whether it is possible to format elements of the final
>combination.
>
>
>For example, one of my fields is *volume *and the other is *issue*.  Each
>of these fields contains a number.  In the example below, 15 is the
>volume,
>and 4 is the issue.
>
>
>
>Can I create a combination where the contents of the combined field that
>looks like the example below, that is, the volume number is formatted as
>bold, and the issue number appears in brackets?
>
>
>* 15*(4)
>
>
>Also, can I combine to number fields so that the combination is separated
>by a dash, for example:
>
>
>345-350
>
>
>
>
>
>
>
>
>Thanks!
>_______________________________________________
>FMPexperts mailing list
>[hidden email]
>http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au


_______________________________________________
FMPexperts mailing list
[hidden email]
http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Combining fields and formatting result

Richard DeShong
Hi Tas,

And unless you have a reason for building it as a list first, you can
just concatenate the fields is a calc.

Field1 & "  " & Field2 & "  " & Field3

Also, in the FM calc engine, you can insert line breaks into a calc -
they are not seen as a delimiter.  So, using Jon's example, you can
create a calc like:

some_operation(Field_1) & " " &
another_operation(field_2) & " " &
leave_me_alone(field_3) & " " &
some_more_stuff(field4)

As for the "dash" example, the calc below would NOT be seen as a subtraction:

"(" & Field1 & "-" & Field2 & ")"

In the below example Field2 would be subtracted from Field1 and the result would be displayed in parenthesis:

"(" & Field1 - Field2 & ")"

Note:  If you do want to subtract, then it is best practice to wrap the
calc in parenthesis, as:

"(" & ( Field1 - Field2 ) & ")"


On 6/7/2017 7:26 PM, John Weinshel wrote:

> You'll notice this list does not respect formatted text, so we can't see
> any bolding, etc.
>
> You can do whatever you like to each element. Be aware, though, that
> creating field definitions from these kinds of calculations will work, but
> it's not usually the most economical approach. Better if you can use
> scripts to apply the same logic to set some value to the same calculation.
>
> But if you are new to Filemaker and not yet comfortable with scripting, go
> ahead and build the calcs you need.
>
> The basic idea is as follows:
>
> List(
>     some_operation(Field_1);
>     another_operation(field_2);
>     leave_me_alone(field_3);
>     some_more_stuff(field4);
> )
>
> ...where each line ends in a semi-colon. That will return a list, and
> you'll need to substitute out the returns to get a single line string,
> similar to what you have already worked out.*
>
>
> The made-up functions wrapping the fields could be text formatting, i.e.:
>
> TextStyleAdd(field_4; bold)
>
> ...or an arithmetic operation:
>
> (field_3*field_4)
>
> ...or concatenated text:
>
> "foobar " & field_5
>
> ... or:
>
> "(" & field_5 & ")"
>
> If you just want the field value in the list, don't wrap it in anything:
>
> List(
>     some_operation(Field_1);
>     another_operation(field_2);
>     field_3;
>     some_more_stuff(field4);
> )
>
>
> If arithmetic operations break because they are treating the fields as
> text, you can use GetAsNumber(your_field) to ensure the data type.
>
> Conversely, take care in your last example ('345-350') that 350 is not
> subtracted from 345. You can use double quotes or GetAsText() to coerce
> where needed.
>
> Good luck.
>
> John Weinshel
> Datagrace, LLC
>
>
>
> *You can use Substitute() again, against the entire expression. Easier to
> read is a Let() statement:
>
> Let(
>    [
>     my_expression =
>       List(
>       some_operation(Field_1);
>       another_operation(field_2);
>       leave_me_alone(field_3);
>       some_more_stuff(field4);
>       );
>
>     result = Substitute(my_expression; "¶"; "")
>    ];
> result
> )
>
>
>
>
>
>
>
> On 6/7/17, 6:47 PM, "Tas Karas" <[hidden email]> wrote:
>
>> I'm a FileMaker newbie, and found this method of combining two separate
>> fields into one.
>>
>>
>>
>> Substitute (List(Field_1, Field_2, Field_3, etc); "¶", " ")
>>
>>
>>
>>
>> Just wondering whether it is possible to format elements of the final
>> combination.
>>
>>
>> For example, one of my fields is *volume *and the other is *issue*.  Each
>> of these fields contains a number.  In the example below, 15 is the
>> volume,
>> and 4 is the issue.
>>
>>
>>
>> Can I create a combination where the contents of the combined field that
>> looks like the example below, that is, the volume number is formatted as
>> bold, and the issue number appears in brackets?
>>
>>
>> * 15*(4)
>>
>>
>> Also, can I combine to number fields so that the combination is separated
>> by a dash, for example:
>>
>>
>> 345-350
>>
>>
>>
>>
>>
>>
>>
>>
>> Thanks!
>> _______________________________________________
>> FMPexperts mailing list
>> [hidden email]
>> http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
>
> _______________________________________________
> FMPexperts mailing list
> [hidden email]
> http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au

--
Richard DeShong
Logic Tools
510-642-5123 office
925-285-1088 cell

_______________________________________________
FMPexperts mailing list
[hidden email]
http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Combining fields and formatting result

John Weinshel
What Richard said.

John

On 6/8/17, 9:41 AM, "Richard DeShong" <[hidden email]> wrote:

>Hi Tas,
>
>And unless you have a reason for building it as a list first, you can
>just concatenate the fields is a calc.
>
>Field1 & "  " & Field2 & "  " & Field3
>
>Also, in the FM calc engine, you can insert line breaks into a calc -
>they are not seen as a delimiter.  So, using Jon's example, you can
>create a calc like:
>
>some_operation(Field_1) & " " &
>another_operation(field_2) & " " &
>leave_me_alone(field_3) & " " &
>some_more_stuff(field4)
>
>As for the "dash" example, the calc below would NOT be seen as a
>subtraction:
>
>"(" & Field1 & "-" & Field2 & ")"
>
>In the below example Field2 would be subtracted from Field1 and the
>result would be displayed in parenthesis:
>
>"(" & Field1 - Field2 & ")"
>
>Note:  If you do want to subtract, then it is best practice to wrap the
>calc in parenthesis, as:
>
>"(" & ( Field1 - Field2 ) & ")"
>
>
>On 6/7/2017 7:26 PM, John Weinshel wrote:
>> You'll notice this list does not respect formatted text, so we can't see
>> any bolding, etc.
>>
>> You can do whatever you like to each element. Be aware, though, that
>> creating field definitions from these kinds of calculations will work,
>>but
>> it's not usually the most economical approach. Better if you can use
>> scripts to apply the same logic to set some value to the same
>>calculation.
>>
>> But if you are new to Filemaker and not yet comfortable with scripting,
>>go
>> ahead and build the calcs you need.
>>
>> The basic idea is as follows:
>>
>> List(
>>     some_operation(Field_1);
>>     another_operation(field_2);
>>     leave_me_alone(field_3);
>>     some_more_stuff(field4);
>> )
>>
>> ...where each line ends in a semi-colon. That will return a list, and
>> you'll need to substitute out the returns to get a single line string,
>> similar to what you have already worked out.*
>>
>>
>> The made-up functions wrapping the fields could be text formatting,
>>i.e.:
>>
>> TextStyleAdd(field_4; bold)
>>
>> ...or an arithmetic operation:
>>
>> (field_3*field_4)
>>
>> ...or concatenated text:
>>
>> "foobar " & field_5
>>
>> ... or:
>>
>> "(" & field_5 & ")"
>>
>> If you just want the field value in the list, don't wrap it in anything:
>>
>> List(
>>     some_operation(Field_1);
>>     another_operation(field_2);
>>     field_3;
>>     some_more_stuff(field4);
>> )
>>
>>
>> If arithmetic operations break because they are treating the fields as
>> text, you can use GetAsNumber(your_field) to ensure the data type.
>>
>> Conversely, take care in your last example ('345-350') that 350 is not
>> subtracted from 345. You can use double quotes or GetAsText() to coerce
>> where needed.
>>
>> Good luck.
>>
>> John Weinshel
>> Datagrace, LLC
>>
>>
>>
>> *You can use Substitute() again, against the entire expression. Easier
>>to
>> read is a Let() statement:
>>
>> Let(
>>    [
>>     my_expression =
>>       List(
>>       some_operation(Field_1);
>>       another_operation(field_2);
>>       leave_me_alone(field_3);
>>       some_more_stuff(field4);
>>       );
>>
>>     result = Substitute(my_expression; "¶"; "")
>>    ];
>> result
>> )
>>
>>
>>
>>
>>
>>
>>
>> On 6/7/17, 6:47 PM, "Tas Karas" <[hidden email]> wrote:
>>
>>> I'm a FileMaker newbie, and found this method of combining two separate
>>> fields into one.
>>>
>>>
>>>
>>> Substitute (List(Field_1, Field_2, Field_3, etc); "¶", " ")
>>>
>>>
>>>
>>>
>>> Just wondering whether it is possible to format elements of the final
>>> combination.
>>>
>>>
>>> For example, one of my fields is *volume *and the other is *issue*.
>>>Each
>>> of these fields contains a number.  In the example below, 15 is the
>>> volume,
>>> and 4 is the issue.
>>>
>>>
>>>
>>> Can I create a combination where the contents of the combined field
>>>that
>>> looks like the example below, that is, the volume number is formatted
>>>as
>>> bold, and the issue number appears in brackets?
>>>
>>>
>>> * 15*(4)
>>>
>>>
>>> Also, can I combine to number fields so that the combination is
>>>separated
>>> by a dash, for example:
>>>
>>>
>>> 345-350
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> Thanks!
>>> _______________________________________________
>>> FMPexperts mailing list
>>> [hidden email]
>>> http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
>>
>> _______________________________________________
>> FMPexperts mailing list
>> [hidden email]
>> http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
>
>--
>Richard DeShong
>Logic Tools
>510-642-5123 office
>925-285-1088 cell
>
>_______________________________________________
>FMPexperts mailing list
>[hidden email]
>http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au


_______________________________________________
FMPexperts mailing list
[hidden email]
http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Combining fields and formatting result

Tom Fitch
In reply to this post by Richard DeShong
Also note that if you simply want to display the fields on a layout,
you can achieve this with no extra calculations by using merge fields,
inline with whatever other text you require, and formatted using the
standard formatting commands.

Tom Fitch
FileMaker Pro Certified Developer
Portland, Oregon


On Thu, Jun 8, 2017 at 9:41 AM, Richard DeShong <[hidden email]> wrote:

> Hi Tas,
>
> And unless you have a reason for building it as a list first, you can just
> concatenate the fields is a calc.
>
> Field1 & "  " & Field2 & "  " & Field3
>
> Also, in the FM calc engine, you can insert line breaks into a calc - they
> are not seen as a delimiter.  So, using Jon's example, you can create a calc
> like:
>
> some_operation(Field_1) & " " &
> another_operation(field_2) & " " &
> leave_me_alone(field_3) & " " &
> some_more_stuff(field4)
>
> As for the "dash" example, the calc below would NOT be seen as a
> subtraction:
>
> "(" & Field1 & "-" & Field2 & ")"
>
> In the below example Field2 would be subtracted from Field1 and the result
> would be displayed in parenthesis:
>
> "(" & Field1 - Field2 & ")"
>
> Note:  If you do want to subtract, then it is best practice to wrap the calc
> in parenthesis, as:
>
> "(" & ( Field1 - Field2 ) & ")"
>
>
>
> On 6/7/2017 7:26 PM, John Weinshel wrote:
>>
>> You'll notice this list does not respect formatted text, so we can't see
>> any bolding, etc.
>>
>> You can do whatever you like to each element. Be aware, though, that
>> creating field definitions from these kinds of calculations will work, but
>> it's not usually the most economical approach. Better if you can use
>> scripts to apply the same logic to set some value to the same calculation.
>>
>> But if you are new to Filemaker and not yet comfortable with scripting, go
>> ahead and build the calcs you need.
>>
>> The basic idea is as follows:
>>
>> List(
>>     some_operation(Field_1);
>>     another_operation(field_2);
>>     leave_me_alone(field_3);
>>     some_more_stuff(field4);
>> )
>>
>> ...where each line ends in a semi-colon. That will return a list, and
>> you'll need to substitute out the returns to get a single line string,
>> similar to what you have already worked out.*
>>
>>
>> The made-up functions wrapping the fields could be text formatting, i.e.:
>>
>> TextStyleAdd(field_4; bold)
>>
>> ...or an arithmetic operation:
>>
>> (field_3*field_4)
>>
>> ...or concatenated text:
>>
>> "foobar " & field_5
>>
>> ... or:
>>
>> "(" & field_5 & ")"
>>
>> If you just want the field value in the list, don't wrap it in anything:
>>
>> List(
>>     some_operation(Field_1);
>>     another_operation(field_2);
>>     field_3;
>>     some_more_stuff(field4);
>> )
>>
>>
>> If arithmetic operations break because they are treating the fields as
>> text, you can use GetAsNumber(your_field) to ensure the data type.
>>
>> Conversely, take care in your last example ('345-350') that 350 is not
>> subtracted from 345. You can use double quotes or GetAsText() to coerce
>> where needed.
>>
>> Good luck.
>>
>> John Weinshel
>> Datagrace, LLC
>>
>>
>>
>> *You can use Substitute() again, against the entire expression. Easier to
>> read is a Let() statement:
>>
>> Let(
>>    [
>>     my_expression =
>>       List(
>>       some_operation(Field_1);
>>       another_operation(field_2);
>>       leave_me_alone(field_3);
>>       some_more_stuff(field4);
>>       );
>>
>>     result = Substitute(my_expression; "¶"; "")
>>    ];
>> result
>> )
>>
>>
>>
>>
>>
>>
>>
>> On 6/7/17, 6:47 PM, "Tas Karas" <[hidden email]> wrote:
>>
>>> I'm a FileMaker newbie, and found this method of combining two separate
>>> fields into one.
>>>
>>>
>>>
>>> Substitute (List(Field_1, Field_2, Field_3, etc); "¶", " ")
>>>
>>>
>>>
>>>
>>> Just wondering whether it is possible to format elements of the final
>>> combination.
>>>
>>>
>>> For example, one of my fields is *volume *and the other is *issue*.  Each
>>> of these fields contains a number.  In the example below, 15 is the
>>> volume,
>>> and 4 is the issue.
>>>
>>>
>>>
>>> Can I create a combination where the contents of the combined field that
>>> looks like the example below, that is, the volume number is formatted as
>>> bold, and the issue number appears in brackets?
>>>
>>>
>>> * 15*(4)
>>>
>>>
>>> Also, can I combine to number fields so that the combination is separated
>>> by a dash, for example:
>>>
>>>
>>> 345-350
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> Thanks!
>>> _______________________________________________
>>> FMPexperts mailing list
>>> [hidden email]
>>> http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
>>
>>
>> _______________________________________________
>> FMPexperts mailing list
>> [hidden email]
>> http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
>
>
> --
> Richard DeShong
> Logic Tools
> 510-642-5123 office
> 925-285-1088 cell
>
>
> _______________________________________________
> FMPexperts mailing list
> [hidden email]
> http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
_______________________________________________
FMPexperts mailing list
[hidden email]
http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
Loading...