Local Storage for Macros

Macros can Now Remember Settings and Other Data

January 23, 2018

An update for Onetastic is available today with two new functions to read and write data on the local computer, similar to how Windows Registry works. This is called Local Storage. Data stored in Local Storage is available across multiple executions of the same macro. These new functions are:

These can be used to save any data type other than an Object. If it is an Array, it cannot contain Objects.. The data is stored in a key-value pair store on the computer and is available from the same macro in the current or subsequent executions. See more info on how to use these functions in the documentation.

Saving Macro Settings

One very useful way to use this persistent data is to store and remember user input for subsequent executions of a macro. For instance Search & Replace macro remembers the values user entered in the dialog box so that it can present those same values when the user runs the macro again. Similarly settings in a macro, like which day of the week the calendar should start for Insert Monthly Calendar macro, can be stored and retrieved.

These and a few more macros are already updated to take advantage of this. This will greatly improve usability of these macros, so that if you are using them with non-default settings, you won't have to keep changing the settings, or if you use Search & Replace multiple times with same values, you won't have to re-type them.

Debugging Local Storage

Object Browser in Macro Debugger will display the values stored under the Local Storage section at the bottom:

Object Browser Local Storage

Comments

Name
Comment
StavGold - 2018-09-24
Hi Omer,

I'm using this feature to implement a macro that copies a column of data from a table in one page of a notebook, then pastes that column of data into another column in a table on another page of a notebook. There are a few problems I'm noticing with this approach:

* Line breaks aren't respected. After I perform the copy paste, all the lines are bunched together and I have to re-add them manually.
* Tags (like the to-do checkbox) aren't respected either.

Is there a better way to do this? Do you think it'd be doable to make line breaks a thing for local storage in the near future?

Thanks a ton for the work so far.
Christian.carteron - 2018-03-29
bonjour
cela peut être interessant d'imprimer le resultat de one calendar, est-ce possible ?
merci d'avance
brian oconnor - 2018-03-20
Hi Omer: I have a section template I use when adding new employees to a notebook,I'm looking for a macro that will take a list of names on an excel spreadsheet and create a new section using the section template and rename it with the name from the spreadsheet list. Any suggestions?

Other Posts

Show all posts