MoneyWorks Manual
SetPersistent (table, key1, key2, array)
Definition: Updates a record with values from an associative array using the key values as for GetPersistent().
Here is an example of using a mutex and persistent storage to execute something at most once a week by only one user without risk of a race condition whereby two users might look at the user2 persistent storage record at the same time:
on Load
if GetMutex("rate_update")
let values = GetPersistent("user2", kMyDevKey, "last_update")
if values["date1"] < Today() - 7
GetRates() // do weekly thing
let values["date1"] = Today()
SetPersistent("user2", kMyDevKey, "last_update", values)
endif
ReleaseMutex("rate_update")
endif
end
See the table below for tables and fields supported by GetPersistent and SetPersistent.
| table | key1 | key2 | fields |
| user | 7 character key of your choosing | none | data |
| user2 | 32 bit numeric developer key. You may use any value from #80000000-#8FFFFFFF for internal projects. For projects that you wish to distribute to others, please contact Cognito for a key range that you can use exclusively. | 27 character key of your choosing | int1, int2, float1, float2, date1, date2, text1, text2, text |
| lists | 15 char listID(may or may not be a listID known to the Validation Lists list) | 15 character list item | comment |
| offledger | must be "USR" (you can Get the "CUR" (currency) records if you wish, but you may not Set them) | 15 character name | description, balance91..balance00, budget29..budget00, budgetnext01..budgetnext18 |
In MoneyWorks 7.1 and later, the fourth parameter may be omitted: this will cause the record identified by the key(s) to be deleted. In this case the return value is a boolean indicating success or failure. If the key parameters contain wildcards, then all matching records will be deleted.
Availability: MWScript