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

Function 在此自定义函数中添加第二个地址行(Filemaker Pro),function,filemaker,Function,Filemaker,我想在这个自定义函数中添加第二个地址字段(即Apt.#101)。如果您愿意,您可以解释这个案例(不是IsEmpty)是如何工作的,我愿意尝试在我自己的文件中添加第二个地址字段… Let( [ x1 = Name; x2 = x1 & Case(not IsEmpty(Address); Case(not IsEmpty(x1); "¶") & Address); x3 = Case(not IsEmpty(City); City & ", ") &

我想在这个自定义函数中添加第二个地址字段(即Apt.#101)。如果您愿意,您可以解释这个案例(不是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

)

我建议删除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 )
arg为9999(或其他适当大的值)的LeftWords函数将删除任何尾随的换行符或空格,如果城市、州和邮政编码都为空,则可能会出现这种情况。

使用
List()
函数:

List( 
 Address Line 1;
 Address Line 2;
 Substitute( List( Sity, Upper( State ); ZIP ); "¶"; " " );
 Country ) )
这里的想法是,
List()
函数忽略空值,因此您不必测试它们是否为空。对于地址行,它将自动忽略空值;对于状态ZIP行,它将为您提供一个有效的列表,您所要做的就是替换分隔符

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

/* Join( separator; list *) */
Substitute( list; "¶"; separator )
这将使它更简单

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