Dummy runs before apply?

Hi

I have the following files:

subfile1.dat:

+prog template $ subfile 1
let#var1 1
end

subfile2.dat:

+prog template $ subfile 1
let#var1 1
end

I wish to run these two files from a main.dat file.
I would imagine the main.dat file should look like this:

+apply subfile1.dat
+apply subfile2.dat

But this doesn’t work with the error message There are no active modules.

As such, I need a dummy module to run prior to any +apply commands, thereby the file looks like this:

+prog template $ dummy
end
+apply subfile1.dat
+apply subfile2.dat

This would be okay, but every now and then I only need to run subfile2, which I would then run by clicking the +apply subfile2.dat in the Module Tree. But again, I get the same error message There are no active modules.

That means that in order to run the files individually, I need to set up the main file like this, and run it by chapters instead:

!#!chapter subfile1
+prog template $ dummy
end
+apply subfile1.dat

!#!chapter subfile2
+prog template $ dummy
end
+apply subfile2.dat

Do I really need this dummy run in order to run an +apply command? Isn’t there some clever workaround?

Don’t think so.
Apply is meant for using results from on the fly calculations and only works if you are calculating a module first.

If your files aren’t being generated during the calculations use:
#Include subfile1.dat
#Include subfile2.dat
instead.

Ah that is a decent work around.

Initially I’ll use #include then. If, at some point, I begin to generate something during the run, I’ll have to swallow the bitter pill and switch to +apply.

Thanks!

In general you should use #include (more basic/safer/etc).

Also with #include you aren’t limited to entire subroutines (+prog … end), but you can use snippets.

Try to limit +Apply to only the subroutine that actually needs on the fly data.

Understood. Due to Sofistiks limitations I usually end up having to use Python to generate data during the runs, so I usually end up having to use +apply anyway, so that’s the reason I went there straight away :slight_smile: