Dear all,
I am trying to execute a mata function in different but related ado-files, but I don't know how to do it efficiently. Right now, I have the same mata functions at the end of each ado-file. Let me explain.
I have an ado file called `xyz.ado` that executes several other subroutines depending on the needs of the user. For instance, it may execute routine `xyz_load.ado` or `xyz_create.ado` or `xyz_estimate.ado`. Each of these ado-files uses a mata function called `hello()`. My problem is that if I defined `hello()` as shown below, it is not accessible by any of the `xyz_SUBROUTINES.ado` adofiles,
The restrictions that I face are the following:
1. Each of the subroutnines `xyz_SUBROUTINES.ado` must remain as independent ado-files. That is, I cannot do the following,
2. the whole `xyz` package is used for several people in my team, so the mata function should available in all the subrountines each time the user executes `xyz`
3. all the files of the package `xyz` won't be placed in the same directory path in the computer of each of the members of my team. That is, some people may have it in c:/ado/plus/x, others in c:/ado/personal/x, and others in c:/onedrive/stata/ (the ones with the latter directory path structure have already included such a paths in searching directories of stata using adopath ++)
So, my questions are the following.
1. Is it possible to compile a mata library from a .mata file directly from within an ado-file?
2. When I placed the in `xyz.mata` with all my mata function in c:/ado/plus/x, and then execute `do xyz.mata` directly within my `xyz.ado` it does not read the version in c:/ado/plus/x but the one in my current directory. How do I make Stata to look for .mata file in the searching directories stored in the global macro S_ADO?
Thank you so much for your help.
Best,
I am trying to execute a mata function in different but related ado-files, but I don't know how to do it efficiently. Right now, I have the same mata functions at the end of each ado-file. Let me explain.
I have an ado file called `xyz.ado` that executes several other subroutines depending on the needs of the user. For instance, it may execute routine `xyz_load.ado` or `xyz_create.ado` or `xyz_estimate.ado`. Each of these ado-files uses a mata function called `hello()`. My problem is that if I defined `hello()` as shown below, it is not accessible by any of the `xyz_SUBROUTINES.ado` adofiles,
Code:
program define xyz . xyz_load ... . end version 15 mata: void hello() { printf("hello people\n") } end
The restrictions that I face are the following:
1. Each of the subroutnines `xyz_SUBROUTINES.ado` must remain as independent ado-files. That is, I cannot do the following,
Code:
program define xyz . . . xyz_load ... . . . end program define xyz_load . mata: hello() . end mata: void hello() { printf("hello people\n") } end
3. all the files of the package `xyz` won't be placed in the same directory path in the computer of each of the members of my team. That is, some people may have it in c:/ado/plus/x, others in c:/ado/personal/x, and others in c:/onedrive/stata/ (the ones with the latter directory path structure have already included such a paths in searching directories of stata using adopath ++)
So, my questions are the following.
1. Is it possible to compile a mata library from a .mata file directly from within an ado-file?
2. When I placed the in `xyz.mata` with all my mata function in c:/ado/plus/x, and then execute `do xyz.mata` directly within my `xyz.ado` it does not read the version in c:/ado/plus/x but the one in my current directory. How do I make Stata to look for .mata file in the searching directories stored in the global macro S_ADO?
Thank you so much for your help.
Best,
Comment