I want to load an external Magma file within another Magma file. (Both files are saved in the same directory.) I want to be able to quickly change which external file is being loaded, ideally at the beginning of the file making the load call, so that I can easily run the same code with various inputs.
(The external file contains computations, whose ultimate result is used by the file making the load call. These computations vary depending on the object being analyzed.)
I tried creating a string-type variable that stores the external file's name, then using Magma's load command with this variable. For example,
fileName := "externalMagmaFile.txt";
load fileName;
However, this results in the error
User error: Could not open file "fileName" (No such file or directory)
The same error results when I include double quotes around the external file name:
fileName := "\"externalMagmaFile.txt\"";
load fileName;
It seems that, for the load command, Magma interprets the variable name as the string specifying the file name, instead of first evaluating the variable, then executing load.
(I am using Magma V2.23-1 on MacOS Version 10.15.5.)
Can I use a variable with the load command in Magma? If yes, how?
This is awful, but might work.
– David A. Craven Jun 30 '20 at 22:13Unfortunately, when I use this approach in my full code, Magma returns
– ev.gal Jul 02 '20 at 19:26User error: bad syntax. This may be related to theloadcommand being inside anifstatement; see this (unanswered) post on Stack Overflow. In my case, Magma seems to ignore code within theifstatement preceding theloadcommand, including the creation of the dummy load file.evalcommand, but you can only use it with expressions and not statements... – xxxxxxxxx Jul 10 '20 at 01:25FEFunctionsthat uses conditionals to build the appropriate functions, and it can return the appropriate functions. So if you have functionsFE1andFE2that might behave differently depending on properties of the listL,FE1, FE2 := FEFunctions(L)can decide which functions are appropriate and return them. – xxxxxxxxx Jul 12 '20 at 18:34loadcommand is mostly kind of awkwardly implemented). – xxxxxxxxx Jul 12 '20 at 18:37