Result Commands

Home, Up: Results

 

On this page:

$ and hy, Result Control Codes, Result Commands, Writing Directly to Result File hy, Notes.

 

$ and hy

To repeat:

After a calculation the pseudo variable $ holds the unformatted result, its former value becomes the new value of $$.

The formatted result is also written to the file hy, except in silent mode or within a script before the script has ended.

Accumulation mode allows more than one result to be written to the file hy.

Assigning a value to a variable does not update $ or hy.

The content of hy can be used in a calculation as an insert file, (hy), or can be read into a user-defined element, @myude = (hy).

 

Result Control Codes

As already discussed on the previous page, these codes can be appended to a calculation line, separated by a space.

... # means silent mode, the result will not be written to hy.

... & means accumulation mode, the result will be added to the current content of hy.

... && also means accumulation mode, the result will be added to the current content of hy, but in a new line.

Silent mode and accumulation mode only apply to the particular calculation line.

 

Result Commands

(About buffer mode see next page, The Result Buffer.)

= -- show the last result (the value of $) in the currently chosen format (nothing gets changed).

== -- show the last result (the value of $) in decimal format with up to 18 digits (nothing gets changed).

$ -- write the last result (the value of $) to hy in the currently specified format. The previous content of hy gets overwritten, $$ is not changed. Not allowed in buffer mode and in scripts. See "Notes" below.

& -- clear the result file hy (hy is not deleted, but will be empty). If buffer mode is on, clear the buffer. $ and $$ are not changed. See also next paragraph below.

0 -- technically this is not a command but a calculation. $ is set to 0, this also becomes the content of hy, $$ assumes the previous value of $.

&& -- add a line break to the result file hy. If buffer mode is on, insert a line break in the buffer.

 

HY -- show the content of the result file hy (unless it has more than 40 lines or 4000 characters).

EDIT -- open the result file hy in the chosen external editor (by default notepad.exe).

COPY -- copy the content of the result file hy to the Windows clipboard (previous content of the clipboard will be overwritten). Not allowed in buffer mode.

COPYALL ON -- turn copy to clipboard mode on, all results will be copied to the clipboard (each time overwriting the previous content).

COPYALL OFF -- turn copyall mode off.

COPYALL -- show current copyall mode (ON or OFF).

 

Writing Directly to Result File hy

The command & lets you directly write one or more values to hy -- these can be numbers, constants (including pseudo constants) or variables (including pseudo variables $ and $$).

The previous content of hy will be overwritten. The values of $ and $$ will remain unaffected.

 

& value1 value2 ... -- clear result file hy and write the specified values to hy.

 

Anything other than a number, a constant or an existing variable will cause an error.

Numbers after & can be written in any format, but the & command will always write all values to hy in default decimal format (only the apostrophe format setting will apply).

Operators are not allowed, this includes the large number operators LAKH, MILLION and CRORE.

User-defined elements are allowed, e.g. & @myude, as long as they only contain numbers, constants and variables.

In buffer mode this command works with the buffer.

COPYALL mode does not apply to the & command, you have to use COPY to copy the content of hy to the Windows clipboard.

 

Notes

$ on its own (which is a command, not a calculation line) is meant to update hy after the output format was changed. In copy to clipboard mode (COPYALL ON) the result then gets copied to the clipboard in the new format.

The command $ is not allowed in buffer mode and not allowed in scripts. As a command to view the value of $ you can use the commands = or ==.

$ & and $ && are calculation lines, though, and whether in a script or not write the value of $ to hy or the buffer in accumulation mode. The value of $$ is replaced by that of $.

 

The "write to hy or the buffer" command

& $a $b

is a shorter alternative to

&

$a &

$b &

Clear hy or the buffer, write the value of $a (in a script this needs to be done in accumulation mode), write the value of $b in accumulation mode.

There are two differences, though:

& $a $b writes all values in default decimal format, while $a and $b, being calculations, write their results in the currently chosen format.

& $a $b does not affect the result variables $ and $$, while after the separate lines $a and $b (again, these are calculation lines!) $ has the value of $b, and $$ its previous value of $a.

 

HY and EDIT always refer to the result file hy and do not work with the result buffer (see next page).

Copy to clipboard mode (COPYALL ON) is disabled in buffer mode, in scripts and in loops.

 

Home, Up: Results, Prev: HY and Accumulation Mode, Next: The Result Buffer