I answered a post in the Gold forums recently that reminded me of another of those small nuisance items that tend to plague beginners, and even some who are not beginners but may just be having brain fog. The problem was how to compose a server:database
list in formula language for an @DbLookup when the database was to be made up of parts, and the attempt to use@DbLookup("":"NoCache";"Server":"QuickPlace\\" + "databasdir" + "\\Main.nsf";"QPFolderIndex";"1";2)
was failing. Now, leaving aside other issues such as the quotes that probably should not be around databasedir and other minor changes that I have made from the original question, this is a classic case of list addition gone awry.
Let's just look at the server:database
pair:"Server":"QuickPlace\\" + "databasdir" +"\\Main.nsf"
As shown, the result would be "Serverdatabasdir\\Main.nsf":"QuickPlace\\databasdir\\Main.nsf"
which certainly isn't what is desired. Let's decompose this and see why we get that result. Imagine the question were a:b+c+d
and the result acd:bcd. In this case, the implied parentheses are ((a:b)+c)+d
, so working from the inside out, we get (ac:bc)+d
and then acd:bcd
. We can't rely on the implied parentheses, but must add our own to help the formula language know what we want. So, instead of a:b+c+d
, we should use a:(b+c+d)
, which will then evaluate to a:(bcd)
and then a:bcd
. Given that, our original database argument should be changed from"Server":"QuickPlace\\" + "databasdir" +"\\Main.nsf"
to"Server":("QuickPlace\\" + "databasdir" +"\\Main.nsf")
which will then result in"Server":"QuickPlace\\databasdir\\Main.nsf"
which is what we want. I guess the moral is that it is always better to overutilize parentheses than to underutilize them.
Copyright © 2004 Genii Software Ltd.