2009-12-15 35 views
0

我想在此自定义功能中添加第二个地址栏(即。公寓#101)。如果你愿意,你可以解释的案例(不为IsEmpty是如何工作的,我愿意尝试添加在自己的第二个地址字段...将第二个地址栏添加到此自定义功能中(Filemaker Pro)

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 

) 

回答

0

我建议用做掉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) 

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

1
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 

) 
0

使用List()功能:

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

这里的想法是,List()函数忽略空值,这样你就不必测试它们是否是空。有了地址线,它会自动忽略空容器;用sity-state-ZIP这行会给你一个有效的列表,你所要做的就是替换分隔符。

如果你使用FM先进,定义自定义功能的加入列表与给定的分隔符:

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

这将使它更简单。

相关问题