Level: Intermediate

Sometimes Less Is More Reliable

Update: Make sure to read Tony White’s comment below. It contains important additional information re: the behavior described in this article.

Recently I noticed some code that had worked flawlessly for years was suddenly returning “?” instead of valid values. What it came down to was that I had renamed my file from “JSON Custom Functions” to “JSON Custom Functions for FM 19.5”

Well you know those functions like ValueListItems…

ValueListItems ( fileName ; valueListName )

…that have a fileName argument? The culprit turned out to be that I was using Get(FileName) for that argument, and I needed to instead use "".

All 21 of the design functions are vulnerable to this, ahem, behavior. From the online help —

  • If you specify a filename that contains a period, include the filename extension in the parameter. Otherwise, functions may interpret the period in the filename as the beginning of the filename extension, which can lead to unexpected results.
  • If you specify no filename (""), functions return results for the current file.

Source:  https://help.claris.com/en/pro-help/content/design-functions.html

Bottom line:  When using a design function and referencing the current file, use "" instead of Get(FileName). There’s no down side, and your code won’t break if you decide to add a period to the file name.

6 thoughts on “Sometimes Less Is More Reliable”

  1. Good best practice. Using no filename ("") also protects you from errors when you have multiple open files with the same name… where design functions return results (if I recall correctly) from the first opened file rather than the current file. Thanks!

    1. Excellent point Tony. I did run into this the other day and it was bewildering to say the least. I’d forgotten about that till you mentioned it.

  2. Hi Kevin,
    Thanks, this is really helpful. Have to say I just read the help and didn’t see or get an indication from what was written that this would work.

    1. Hi Bruce, it doesn’t specify that in the specific help articles for the individual functions, but it does say that in the header group for “Design functions” that Kevin links to in his article. But searching for the function, you aren’t likely to stumble on that. I don’t think I even realized that the function groups were help articles themselves.

      1. Note too that this behavior was real for quite a few years before the documentation was updated to include the warning.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.