openmolecules.org

 
Home » DataWarrior » Functionality » Variables in Macros (Variables in Macros)
Re: Variables in Macros [message #1159 is a reply to message #1154] Fri, 04 December 2020 13:40 Go to previous messageGo to previous message
thomas is currently offline  thomas
Messages: 715
Registered: June 2014
Senior Member
You could put a macro into your data file or the users' macro folder, which asks for a selection name, then makes a list from the selection and saves the list into a predefined folder using the given name as part of the file name. The user could then select rows, start the macro, select other rows, start the same macro, select more... and finally close DataWarrior for the Jupyter script to continue.

The macro could look like the following.
(I am not sure, whether it runs with the old 5.2.1; potentially you have to upgrade to the current dev version)
This macro example assumes that the data file contains a column 'Structure-ID'. The saved list is a text file containing values from this column. Note: with the current dev version of DataWarrior you can just copy the macro and use 'Paste Macro' from the DataWarrior Macro-menu. (after adapting the path and 'Structure-ID' to your needs).

<macro name="Save Selection">
<task name="defineVariable">
name=filename
message=Please give a name to your selection
</task>
<task name="newRowList">
listName=selected rows
mode=selected
</task>
<task name="exportRowList">
keyColumn=Structure-ID
listName=selected rows
fileName=/home/thomas/$filename.txt
</task>
<task name="showMessage">
message=Your list has been saved!
</task>
</macro>
 
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:26:16 CET 2024

Total time taken to generate the page: 0.04201 seconds