How can I utilize a dictionary that is stored in a different .scd file? I would prefer not to open the file, just read the contents of its dictionary.
Thanks!
How can I utilize a dictionary that is stored in a different .scd file? I would prefer not to open the file, just read the contents of its dictionary.
Thanks!
As far as I know, there are three possibilities using the method .load
and .loadRelative
as follows:
"xxx/xxx/folderName/fileName.scd".load
if the SCD is located in a different folder than SCD on which you are working.
"fileName.scd".resolveRelative.load
if the SCD is in the same folder of SCD on which you are working.
"fileName.scd".loadRelative
if the SCD is in the same folder of SCD on which you are working.
Would it be helpful for you?
That works, thanks!
In Linux the .loadRelative
method seems to be broken, nevertheless .resolveRelative.load
works!
In what way? In general, troubleshooting requires more information than “it didn’t work” – error messages, stack trace etc.
hjh
With .loadRelative
I am getting the error:
ERROR: can't load relative to an unsaved file
This seems to be an old issue that haven’t been resolved yet:
If the file hasn’t been saved, then it has no path. If it has no path, then relative to what should it resolve?
I’m not sure what resolveRelative is doing differently, but if the intended meaning is “resolve this path relative to the location of the current document” but the current document has no location, then the only outcomes are 1/ error or 2/ undefined behavior. At least the error tells you what the problem was.
hjh
Ok now I see the issue.
I have created a class file .sc
which reads data from a .scd
file stored also in the same folder as the class file. When I invoke the class from another unsaved file, the .loadRelative
which is inside the class hasn’t any path.
I wonder then why the .resolveRelative.load
method works.
Or is it a bad idea to have a class reading data from a local file?
I recall looking at this earlier. resolveRelative
takes into account whether it’s been called directly from a method or not. If from a method, it resolves relative to the method’s source code. loadRelative
doesn’t.
This, you can check for yourself by reading the respective methods’ source code.
In this case, another way to locate the file is thisMethod.filenameSymbol.asString.dirname +/+ "myfilename.scd"
.
hjh