CalcAndWrite
Miscellaneous functions CalcAndWrite
syntax
- CalcAndWrite(item, string message)
description
Since GeoDMS 20.16.0. CalcAndWrite posts the configured string message in the EventLog once item has finished calculating, and results in that same item, unchanged.
It is PhaseContainer’s message without PhaseContainer’s fence. A PhaseContainer also posts a message when it is done, but it exists to serialise work: everything scheduled after it waits for it. If all you want is to be told that something is ready, that synchronisation is a price you did not ask to pay. CalcAndWrite schedules nothing extra and copies nothing — its result is its first argument — so wrapping an item in it does not change what is calculated, only what is reported.
The string message is a string data item: a Parameter writes one line, an Attribute of several strings writes a line each, and — as in PhaseContainer — a single empty string writes nothing. The EventLog line names the item the message belongs to, so several CalcAndWrite calls stay apart.
when nothing is written
Both follow from the result being the argument:
- The item was already calculated. There is then nothing left to finish, and nothing is announced. Wrap the calculation you want to hear about, not a value that is already in hand.
- A Container was wrapped and only a Subitem of it is used. Asking for
wrapped/xresolves straight toxin the source container and never asks CalcAndWrite for its own result. Wrap the item you want announced, rather than its container. This is the same shape as issue #1167 for PhaseContainer.
example
attribute<Type> expensive_result (Domain) := CalcAndWrite(expensive(x), 'expensive(x) is ready');
writes, when expensive(x) completes:
expensive(x) is ready [[/expensive_result]]
see also
- PhaseContainer - the same message, plus a fence that serialises the calculation