2009-12-15 52 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) 

這將使它更簡單。

相關問題