This question is different from the answer here Infix form of PutAppend ( >>> ) does not work with variable becasue it is dealing with folders and not filenames.
I have a file path which I save to a varible using the FileNameSetter
. I then use the StringJoin
to add the last folder name to this path. When I do this with a notebook file and then use NotebookEvaluate
for example, Mathematica understands that this variable is a file location and executes without a problem. However when I do the same thing for a package and use the Get (or <<)
Mathematica doesn't seem to understand that the variable is a location.
Setting up the file location
FileNameSetter[Dynamic[DashboardFile]];
DashboardFile
SetDirectory[DirectoryName[DashboardFile]]
PackageLocation = DirectoryName[DashboardFile] <> "Packages"
"\\\\ecsdbn-srv-02\\lara_jordan$\\Cleaner Kumba\\my redev\\tabview \
v1.6.nb"
"\\\\ecsdbn-srv-02\\lara_jordan$\\Cleaner Kumba\\my redev"
"\\\\ecsdbn-srv-02\\lara_jordan$\\Cleaner Kumba\\my redev\\Packages"
Setting up the package location
PackageA = PackageLocation <> "\\HA1Package.m"
<< PackageA
<< "\\\\ecsdbn-srv-02\\lara_jordan$\\Cleaner Kumba\\my redev\\Packages\\HA1Package.m"
"\\\\ecsdbn-srv-02\\lara_jordan$\\Cleaner Kumba\\my redev\\Packages\\HA1Package.m"
Get::noopen: Cannot open PackageA. >>
$Failed
In the third line in the code above I have simply copied and pasted the value of PackageA
just to the right on the <<
so I know that the location stored in the variable PackageA
is valid.
I need this to work becasue I have hundreds of packages where each new user will just be asked to enter one file location that will automatically be used for all packages.
Put
. Your question will not be deleted, and will serve as a signpost for others to find the original question. +1 (In brief: useGet[PackageA]
) $\endgroup$<<
(and>>
and>>>
) in a highly unusual way: anything to the right of these operators is recognized as a String, even without the" "
marks. Therefore your code is trying to read in a file with a literal name ofPackageA
. $\endgroup$