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?
Here is sample code illustrating the approach proposed by @DavidCraven. (The file
realFile.txtcontains the Magma commands we desire to load.)