openmolecules.org

 
Home » DataWarrior » Functionality » Variables in Macros (Variables in Macros)
Variables in Macros [message #1154] Thu, 03 December 2020 11:42 Go to previous message
zsolt
Messages: 4
Registered: December 2020
Junior Member
Hello DW gurus!

Thanks for the awesome product and making it open source - it is a great piece of software indeed.

I would like to use user-defined strings in various fields of the macros - e.g. when saving a file using the saveTextFile task, I would like to be able to compose the fileName property of the macro task from a constant directory prefix and a filename that is defined by the user on the UI - e.g. by using a defineVariable task. I haven't been able to make it work so far. (#ask# works here, but I would not like to give the user complete freedom to select the destination file, because I would like to parse the generated files later using other software so I need a predictable place. I tried variable substitutions like #variablename#, $variablename, ${variablename} and various combinations of these..) If you have a link to the relevant part of the documentation, that would be great. I am not sure if I can do loops and conditions in macro code or mimic it somehow making use of the expression parser and perhaps goto. (I found the generic macro page on the website, and the expression parser page but not much about the macro syntax. What I know is mostly from exporting various macros and reading the exported file. Also, I have seen screenshots on the Internet about the Macro Editor view displaying some help about the tasks but this does not appear for me.)

My scenario in more detail: for now I would only like to use the selection functionality ("lasso tool") of the 2D or 3D view. A script in a Jupyter notebook would do some calculation on data, then eventually start up DataWarrior with this data loaded, then have it generate a plot via macros. Then users would apply the lasso tool to create and save multiple selections, and close Datawarrior afterwards. The Jupyter notebook would resume running, it would parse these saved selections so they are available for further processing under the names specified by the user. I would like to provide this functionality with the least amount of extra clicking and typing. So optimally all the user would need to do is select the compounds and give the selection a name - repeated multiple times - then close the main window when s/he is finished.

One workaround I have now is not to let the user specify the file names, instead have macros they can click to save to selection-0, selection-1 ... etc. and these would generate predictable file names. However then they have to keep in mind what was in selection-n: it would be better if they had to just come up with a name once they create the selection and that could be the name of the file..

If this is not possible currently using macros I am thinking about writing a new macro myself and add it to Datawarrior in a jar. If you have some documentation pointers for this that would also be great.



Versions:
Datawarrior
5.2.1

Java (datawarrior bundled)
openjdk version "1.8.0_232"
OpenJDK Runtime Environment (build 1.8.0_232-BellSoft-b10)
OpenJDK 64-Bit Server VM (build 25.232-b10, mixed mode)

OS
Linux 5.4.0-56-generic #62~18.04.1-Ubuntu SMP Tue Nov 24 10:07:50 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux - "Ubuntu 18.04.4 LTS

Many thanks for your help in advance.
Zsolt

 
Read Message
Read Message
Read Message
Previous Topic: Loop over columns for calculations
Next Topic: Option to Display Table Only
Goto Forum:
  


Current Time: Fri Nov 22 22:49:15 CET 2024

Total time taken to generate the page: 0.04013 seconds