将第二个地址行添加到此自定义函数中 (Filemaker Pro)

发布于 2024-08-15 04:00:55 字数 523 浏览 7 评论 0原文

我想在此自定义函数中添加第二个地址字段(即 Apt. #101)。如果您愿意,您可以解释 Case(不是 IsEmpty)如何工作,我愿意尝试在自己中添加第二个地址字段...

Let(
[
    x1 = Name;
    x2 = x1 & Case(not IsEmpty(Address); Case(not IsEmpty(x1); "¶") & Address);
    x3 = Case(not IsEmpty(City); City & ", ") & Case(not IsEmpty(State); Upper ( State ) & " ") & Zip;
    x4 = x2 & Case(not IsEmpty(x3); "¶") & x3;
    x5 = x4 & Case(not IsEmpty(Country); Case( not IsEmpty(x4); "¶") & Country)
];

    x5

)

I want to add a second Address field into this custom function (ie. Apt. #101). If you wanted, you could explain how the Case(not IsEmpty works and I would be willing to attempt to add the second address field in myself...

Let(
[
    x1 = Name;
    x2 = x1 & Case(not IsEmpty(Address); Case(not IsEmpty(x1); "¶") & Address);
    x3 = Case(not IsEmpty(City); City & ", ") & Case(not IsEmpty(State); Upper ( State ) & " ") & Zip;
    x4 = x2 & Case(not IsEmpty(x3); "¶") & x3;
    x5 = x4 & Case(not IsEmpty(Country); Case( not IsEmpty(x4); "¶") & Country)
];

    x5

)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

苯莒 2024-08-22 04:00:55
Let( [

   x1 = Customer::FullName;
   x2 = x1 & Case(not IsEmpty(Address1); Case(not IsEmpty(x1); "¶") & Address1);
   x3 = x2 & Case(not IsEmpty(Address2); Case(not IsEmpty(x2); "¶") & Address2);
   x4 = Case(not IsEmpty(City); City & ", ") & Case(not IsEmpty(State); Upper ( State ) & " ") & ZipCode;
   x5 = x3 & Case(not IsEmpty(x4); "¶") & x4 ];

x5

)
Let( [

   x1 = Customer::FullName;
   x2 = x1 & Case(not IsEmpty(Address1); Case(not IsEmpty(x1); "¶") & Address1);
   x3 = x2 & Case(not IsEmpty(Address2); Case(not IsEmpty(x2); "¶") & Address2);
   x4 = Case(not IsEmpty(City); City & ", ") & Case(not IsEmpty(State); Upper ( State ) & " ") & ZipCode;
   x5 = x3 & Case(not IsEmpty(x4); "¶") & x4 ];

x5

)
和我恋爱吧 2024-08-22 04:00:55

我建议取消 let 语句,它似乎使它更加混乱。最终目标是,您想要将一堆地址值连接在一起。如果地址值不为空,则需要在相关元素后面放置一个换行符(或对于城市为逗号+空格)。像这样的东西:

LeftWords (
    Case (not IsEmpty(Customer::FullName) ; Customer::FullName & "¶" ) &
    Case (not IsEmpty(Address1) ; Address1 & "¶" ) &
    Case (not IsEmpty(Address2) ; Address2 & "¶" ) &
    Case (not IsEmpty(City) ; City & ", " ) &
    Case (not IsEmpty(State) ; Upper (State ) & " " ) &
    ZipCode
; 9999 )

参数为 9999(或其他适当大的值)的 LeftWords 函数会删除任何尾随换行符或空格,如果城市、州和邮政编码均为空,则可能会发生这种情况。

I'd recommend doing away with the let statement, it seems to make it more confusing. The end goal is, you want to concatenate a bunch of address values together. If an address value is not empty, you want to put a line break (or a comma + space, for the city) after the element in question. Something like this:

LeftWords (
    Case (not IsEmpty(Customer::FullName) ; Customer::FullName & "¶" ) &
    Case (not IsEmpty(Address1) ; Address1 & "¶" ) &
    Case (not IsEmpty(Address2) ; Address2 & "¶" ) &
    Case (not IsEmpty(City) ; City & ", " ) &
    Case (not IsEmpty(State) ; Upper (State ) & " " ) &
    ZipCode
; 9999 )

The LeftWords function with an arg of 9999 (or some other suitably large value) removes any trailing newline or whitespace, which could happen if city, state, and zip are all empty.

乞讨 2024-08-22 04:00:55

使用 List() 函数:

List( 
 Address Line 1;
 Address Line 2;
 Substitute( List( Sity, Upper( State ); ZIP ); "¶"; " " );
 Country ) )

这里的想法是 List() 函数忽略空值,因此您不必测试它们是否为空。对于地址行,它会自动忽略空值;使用 sity-state-ZIP 行,它将为您提供一个有效的列表,您所要做的就是替换分隔符。

如果您使用 FM Advanced,请定义自定义函数以使用给定分隔符连接列表:

/* Join( separator; list *) */
Substitute( list; "¶"; separator )

这将使事情变得更简单。

Use the List() function:

List( 
 Address Line 1;
 Address Line 2;
 Substitute( List( Sity, Upper( State ); ZIP ); "¶"; " " );
 Country ) )

The idea here is that the List() function ignores empty values, so you don't have to test whether they're empty or not. With address lines it will automatically ignore empties; with sity-state-ZIP line it will give you a valid list and all you have to do is to replace the separator.

If you're using FM Advanced, define a custom function to join a list with a given separator:

/* Join( separator; list *) */
Substitute( list; "¶"; separator )

This will make it simpler.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文