# Include file stored as string variable

**URL:** https://forum.dynare.org/t/include-file-stored-as-string-variable/4502
**Category:** Dynare help (legacy posts)
**Created:** [23 February 2015 12:55 UTC](https://forum.dynare.org/t/include-file-stored-as-string-variable/4502 "2015-02-23T12:55:24Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![ChrisZ](https://forum.dynare.org/letter_avatar_proxy/v4/letter/c/ce7236/32.png) [@ChrisZ](https://forum.dynare.org/u/ChrisZ)
#### Post date: [23 February 2015 12:55 UTC](https://forum.dynare.org/t/include-file-stored-as-string-variable/4502/1 "2015-02-23T12:55:24Z")

</div>

Hi,

when using Dynare 4.4.2, I usually split the model files in calibration, model equations, and others. Some of these files are not located in the same folder but in a subfolder or an other folder on the same directory level. I have already figured out that dynare can handle expressions as `@#include "../model_specs/calibration.mod"` to get the file located somewhere else. However, I have a MATLAB path function running in background which returns the absolute path to the specific files. Is there any possibility to load the string variable returned from the path function e.g. xy directly with something like `@#inlcude xy`?

Thanks in advance. Best,  
Chris

---

<div class="post-metadata">

### Author: ![HoutanBastani](https://forum.dynare.org/user_avatar/forum.dynare.org/houtanbastani/32/5052_2.png) [@HoutanBastani](https://forum.dynare.org/u/HoutanBastani)
#### Post date: [24 February 2015 11:05 UTC](https://forum.dynare.org/t/include-file-stored-as-string-variable/4502/2 "2015-02-24T11:05:02Z")

</div>

Not at the moment.

The macroprocessor does text expansion within the preprocessor and thus does not have direct access to the matlab workspace.

However, I say not at the moment, because it would be possible to add this functionality. In essence, you would pass the matlab variable of your choice at the dynare command line using the -D switch. At the current time, this does not work with the @#include macro command as it’s expecting a quoted string. This could be changed, and I’ll add it to our long to do list and it might just be done in the next version of dynare. It also might not. So, in the meanwhile, you’ll have to hard code these strings.

---

<div class="post-metadata">

### Author: ![HoutanBastani](https://forum.dynare.org/user_avatar/forum.dynare.org/houtanbastani/32/5052_2.png) [@HoutanBastani](https://forum.dynare.org/u/HoutanBastani)
#### Post date: [24 February 2015 13:56 UTC](https://forum.dynare.org/t/include-file-stored-as-string-variable/4502/3 "2015-02-24T13:56:09Z")

</div>

So this has just been fixed in unstable, and will be available in tomorrrow’s snapshot package.

To summarize, you need to do something of the order of the following in Matlab:

```auto
>> xy='/path/to/dir/with/other/modfile/';
>> dynare modfile.mod -Dpath=xy
```

and then, in your modfile, you’ll have:

```auto
@#define othermodfile=path+'othermodfile.mod'
@#include othermodfile
```
