A bug of the function "DataFolderExists"?
YHLien
I just found the function "DataFolderExists" failed to return the result correctly if the hierarchy of the data folders contained at least one folder began with numbers. For example, if the hierarchy looks like root:t:tt:2tt, DataFolderExists("root:t:tt:2tt") will return 0, but if the hierarchy is like root:t:tt:tt2, DataFolderExists("root:t:tt:tt2") will return 1. The same thing happens in the case of root:t:2t:tt2. The most funny thing is that, if you set the default folder to root:t first, and DataFolderExists("2t") will correctly return 1.
Any comment or suggestion?
Liberal names generally need to be quoted with a single quote. This will work:
There is one very tricky exception. If you have a simple name rather than a path in a string, it must NOT be quoted:
Print DataFolderExists("2tt") // RIGHT
You can read about this by executing:
It's pretty difficult to program in a liberal-name-safe way. If you use a liberal name only occasionally, you may write code that is not liberal-name-safe but you might not know it. There are two solutions:
1. Test all of your routines with liberal names.
2. Don't use liberal names.
If you use liberal names, you will need to refresh your memory about the rules by reading the help section referenced above from time-to-time.
May 17, 2011 at 10:40 am - Permalink
DataFolderExists(("root:t:tt:'2tt'")
You can learn more about liberal object names and data folder syntax by typing the following in the command window:
DisplayHelpTopic "Object Names[Liberal Object Names]"
DisplayHelpTopic "Data Folders[Data Folder Syntax]"
They will pull up topics from the help files.
May 17, 2011 at 10:46 am - Permalink
I admit that I totally forget the limitation of the liberal name.
May 17, 2011 at 01:48 pm - Permalink