I know there's a way to make the enter-key on the keyboard confirm the inputdlg() dialog, see here:
http://www.mathworks.de/support/solutions/en/data/1-39UWQT/index.html?product=ML&solution=1-39UWQT
Okay it's a workaround, the problem is, I have to store it in the matlab directory (because as said on the page: "Since it is dependent on several private functions, newid.m will only work if stored in this location.").. The problem now is, I want to make a code which doesn#t rely on user changes in the Matlab directory because of missing privileges... Is there still another (perhaps dirty) way to achieve this behaviour?
Thanks!
Solution:
Copy the newid.m from http://www.mathworks.de/support/solutions/en/data/1-39UWQT/index.html?product=ML&solution=1-39UWQT to a arbitrary folder, e.g. into your projects folder
Go into the folder where the original inputdlg() is stored; you can find this out via which inputdlg (e.g. C:\Program Files\MATLAB\R2011b\toolbox\matlab\uitools\inputdlg.m)
Go into the private-subdirectory and copy the two files getnicedialoglocation.m and setdefaultbutton.m and paste them into your project's folder where the newid.m is located. Now call all your input dialogs by using newid() instead of inputdlg()
Related
Every time I simulate in Dymola, a number of "useless" (for me) files are created in the working directory - i.e. dsfinal.txt, dsin.txt, dslog.txt, dsmodel.c, dymosim.exe. I find it annoying as it messes up my directory.
Is there a way to select only the desired output files to be kept after the simulations, without the need of manually deleting the undesired ones?
Those are temporary, but necessary files for Dymola. As far as I know there is no option to delete them automatically. Of course you could script that, but I don't see a real point to it and those files are used by some functionality - e.g. dsfinal.txt is used when as simulation is continued.
Some notes: Those files are created in the working directory - which should contain temporary files only. The working directory can be set via the GUI using File -> Options -> Settings:
A rather common problem is, that there is a Open and a Load function in Dymola:
As the description states, Load does not influence the working directory, whereas Open sets it to the directory from which a file is opened. The latter is also true for opening files e.g. via a double-click from the explorer. So usually it is better to go with Load.
My advice would be to separate the directories in which models/packages are stored and the working directory. This way the working directories content can be fully deleted basically anytime...
Where can i save my document "function.m", so i can call this function from any code in any path of my pc?
I already made some custom functions, but i dont know where to save those codes to be able to call them from any part.
Save them in a logical place where you can find them back. Then, use addpath to add that folder to MATLAB's search path, i.e. when you use a function it will try that folder as well to find it.
You can do this either per script, or edit startup.m with this, so that it's automatically included when MATLAB starts.
Alternatively to Adriaan's best practice answer, the fastest option is to save your function.m in the %USERPROFILE%/Documents/MATLAB directory on your PC ($home/Documents/MATLAB on Linux and Mac). This directory is on your MATLAB Search Path by default. This might be an acceptable solution if you use the function commonly across different projects.
Finally, there is a "manual" solution: Execute pathtool in MATLAB, add the directory containing your function.m via the GUI and hit save.
I want to export some data from Filemaker. Is there a posibility to start a script with an export dialog were the user defines the export location and store this path in a variable so that the user does not have to define the location for following export scripts?
Thanks for your help!
Dan
If you're willing to use a FileMaker plugin, the free BaseElements plugin has a function called BE_SelectFolder(prompt) which opens an open/save dialog, allows the user to select a folder, and returns the location of the folder as a string. So you'd define two variables
Set Variable [$thePath; value: “BE_SelectFolder("Please choose a folder:")”]
Set Variable [$theRef; value: “"filemac:" & $thePath & "/exportfile.fmp12"”]
(that's for Mac, you'd need to adjust the second variable calc for Windows) and then use $theRef as the file reference to save the exports to.
BaseElements is available from http://www.goya.com.au/baseelements/plugin. It's got a lot of other useful functions besides, it's worth checking out.
There is no FileMaker built-in functionality to return the file path for the exported file.
If the user runs the same export twice in a row, the folder selection dialogue will open at the same location. I suspect this is not what you need.
The easiest way to work around the problem is to use AppleScript on a Mac or VBScript on PC to popup a folder select dialogue, return it back to FileMaker and store in a variable. The rest is down to your workflow.
New in FileMaker 14, from May 2015, in the "Miscellaneus script Step" you may find "Get Directory" which is the right one for your question.
His purpose is described as "Sets a variable to the fully qualified path of a specified folder."
You may also create a new folder, in case of needs, if "Allow Folder Creation" parameter is set.
Note: it is not compatible with FileMaker Go while, instead, you may use it for a RunTime distribution.
I have a custom package that I find myself reusing repeatedly in Dymola models, and I'd like to put this package in a common directory that is automatically loaded whenever I start Dymola. My current strategy is to load the custom package when a model I'm working on is loaded and then save total. This is not elegant because the contents of the custom package end up saved in multiple locations across my hard drive, and if I change one of them, the changes are not reflected everywhere. I would like a more robust way of distributing this custom package to all of my models. Is there a way to tell Dymola to automatically load my custom packaged every time?
The trick is to add the following lines to settings.mos in c:/Users/USERNAME/AppData/Roaming/Dynasim:
Utilities.setenv("MODELICAPATH", "C:\Users\USERNAME\Documents\Dymola");
openModel("c:\Users\USERNAME\Documents\Dymola\UserDefined\package.mo")
The first line adds the directory to the path that Dymola uses to search for packages that have not been loaded prior to the first run of a model, and the second line loads the specified package. These two commands may be somewhat redundant, but I am doing both because I want to make sure my custom packages are on the path in addition to loading the UserDefined package.
Two suggestions. First, you need to add your package to the MODELICAPATH. You'll have to consult the Dymola documentation to figure out exactly what you need to do. But normally, what this means is that you have to set an environment variable that gives a list of directories (; separated) to be searched for your package. Now that will put it in your path so it can find it automatically, but it won't load it until it needs it.
If you want it to always appear in the package browser, you'll probably need to set up a .mos file (script) to load it. Dymola has that capability, but you'll have to read the manual to figure out what that script has to be called and where Dymola expects to find it.
I hope that helps.
In the instalation folder of Dymola 2018 -> insert -> dymola.mos
I've added the lines:
Utilities.setenv("MODELICAPATH", "C:\Users\XXXX\Documents\Dymola");
openModel("C:\Users\XXXX\Documents\Dymola\DCOL\package.mo");
openModel(“C:\Users\XXXX\Documents\Dymola\Annex60 1.0.0\package.mo”);
Now I don't get the utilities sentence, as the DCOL package loads fine without it and the added 'utilities' package in the package menu is useless.
But it does not open the Annex60 package.
I've tried a lot of different combinations and can't get multiple packages to load. I doubt that "cd" and "Advanced.ParallelizeCode", which are also added in the text work.
The accepted answer does not work since Dymola 2017 FD01, as the file settings.mos is not used anymore. User settings are stored in the setup.dymx file instead, located in
C:\Users\USERNAME\AppData\Roaming\DassaultSystemes\Dymola
In contrast to the setup.mos file you can not include custom lines with modelica script in setup.dymx.
The answer using dymola.mos still works, but you need admin privileges to modify this file.
Here is a simple solution which works with all Dyomola versions:
You can pass a .mos-script as first parameter to the dymola.exe.
This can e.g. be done like this:
Create a .mos script somewhere with commands like openModel(), etc.
Create a desktop shortcut to Dymola.exe
Open the properties of the shortcut and add the path to the .mos script in the Target text field. It will then look something like this:
"C:\Program Files\Dymola 2018 FD01\bin64\Dymola.exe" "C:\<some-path>\startup.mos"
Start Dymola with the desktop shortcut. The script will be executed and eventual errors or messages are displayed in the Commands window
Another suggestion where you don't need to hardcode your package into an environment variable of your operating system (and maybe more safe for inexperienced programmers):
Go to the folder where Dymola is installed (e.g. C:\Program Files\Dymola 2020).
Search for the Dymola.mos file in the insert-folder. 'insert' folder
Open the script (e.g., in notepad++)
Add the link(s) to your Dymola-library-package.mo file(s) here with the openModel statement
e.g., openModel("C:/IDEAS/package.mo"); Dymola.mos script
Save the script. Now, every time you open Dymola, your libraries will be loaded automatically.
It sometimes happens that I need to change the behavior of a function. Is there an easy way to find functions (on the matlab path) that use that function?
The way I do this is to look for files that contain the name of the function I'm interested in. Thus, I don't only see who calls my function, but also what signature they use.
In the editor: Edit->Find Files
Start with help deprpt.
EDIT: when I run a dependency report there are 3 checkboxes at the top of the report window. One of these, by default unchecked, is called 'Show parent functions (current folder only)'. That is probably the beginning of what you want but it only works in a single folder.
If you want more than that, I suggest that you try edit deprpt.m.
I would use a tool like grep. I posted a tool called mgrep on the file exchange a few years ago. It can search through entire directories of m-files for any given string, and it searched recursively down into sub-directories. So to find functions in my directories that call fminsearch, I would merely execute this at the command line.
mgrep('fminsearch','.','show','off')
Searching directory(ies)...
/Users/woodchips/Desktop/My_FEX/cylinderfit.m
/Users/woodchips/Desktop/My_FEX/fminspleas.m
/Users/woodchips/Desktop/My_FEX/fminspleas2.m
/Users/woodchips/Desktop/My_FEX/fminspleas3.m
/Users/woodchips/Desktop/My_FEX/fminspleasnnls.m
/Users/woodchips/Desktop/My_FEX/BoundedFSOLVE/fsolvebnd.m
/Users/woodchips/Desktop/My_FEX/FMINSEARCHBND/fminsearchbnd.m
...
you mean like looking for dependencies? that would be tools -> show dependency report