将第二个地址行添加到此自定义函数中 (Filemaker Pro)
我想在此自定义函数中添加第二个地址字段(即 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我建议取消 let 语句,它似乎使它更加混乱。最终目标是,您想要将一堆地址值连接在一起。如果地址值不为空,则需要在相关元素后面放置一个换行符(或对于城市为逗号+空格)。像这样的东西:
参数为 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:
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.
使用
List()
函数:这里的想法是
List()
函数忽略空值,因此您不必测试它们是否为空。对于地址行,它会自动忽略空值;使用 sity-state-ZIP 行,它将为您提供一个有效的列表,您所要做的就是替换分隔符。如果您使用 FM Advanced,请定义自定义函数以使用给定分隔符连接列表:
这将使事情变得更简单。
Use the
List()
function: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:
This will make it simpler.