db48x/doc/commands/dirs.md
Christophe de Dinechin f820ac178f variables: Implement vars and tvars commands
Implement the two commands.
This involves moving the function evaluating type values to the
`object` class, so that we can leverage it.
The `tvars` command accepts both HP-compatible (positive) and
DB48X (negative) type values for filtering.

Fixes: #924

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-05-11 13:00:38 +02:00

5.2 KiB
Executable file
Raw Permalink Blame History

Variables

Variables are named storage for RPL values.

Store (STO)

Store an object into a specified location. For example 2 'ABC' STO stores the value 2 in a global variable named ABC.

Value Name

The Value is copied in a storage location identified by Name. The storage location depends on the type of Name, which can be quoted in an expression:

  • Symbol or integer: The value is stored in a global variable with that name in the current directory, which is created if necessary. Whether integers can be used as variable names depends on the NumberedVariables setting.

  • Local name: The value is stored in the corresponding local variable.

  • Setting name: The value is used for the corresponding setting, as if the setting command had been executed. For example, 16 'Base' STO has the same effect as 16 Base.

  • Text: Value is stored in a named file on the flash storage.

Recall (RCL)

Recall an object from a specified location. For example 'ABC' RCL recalls the value from a global variable named ABC.

NameValue

The Value is fetched from a storage location identified by Name. The storage location depends on the type of Name, which can be quoted in an expression:

  • Symbol or integer: The value is fetched from a global variable with that name in the current directory or any enclosing directory. Whether integers can be used as variable names depends on the NumberedVariables setting.

  • Local name: The value is fetched from the corresponding local variable.

  • Setting name: The value is fetched from the corresponding setting. For example, 'Base' RCL returns the current value as set by Base.

  • Text: Value is fetched from a named file on the flash storage

Flash storage

SwissMicros calculators have built-in flash storage, that can act as a USB disk when the calculator is connected to a computer. DB48X can read and write to this flash storage using the regular STO and RCL commands, simply by giving a text containing the file name as the Name argument of these commands.

The format of the file depends on how the name ends:

  • .txt: the value is stored as text.

  • .48s: the value is stored as source code in text format. This differs from .txt files for text objects, which will be quoted.

  • .48b: the value is stored in version-specific binary format. This format is only guaranteed to be readable by the same firmware version that wrote it, but it is more compact, faster and energy efficient than the source format.

  • .csv: The value is stored in comma-separated values format. This is mostly interesting for arrays and lists, which can be echanged with spreadsheets and other PC applications that can input or output CSV files.

StoreAdd (STO+)

Add a value to the content of a variable

StoreSub (STO-)

Subtract a value from the contents of a variable

StoreMul (STO×)

Multiply the contents of a variable by a value

StoreDiv (STO÷)

Divide the contents of a variable by a value

RecallAdd (RCL+)

Add the content of a variable to a value on the stack

RecallSub (RCL-)

Subtract the contents of a variable from a value on a stack

RecallMul (RCL×)

Multiply a value on the stack by the contents of a variable

RecallDiv (RCL÷)

Divide a value on the stack by the contents of a variable

Increment (INCR)

Add one to the content of a variable

Decrement (DECR)

Subtract one from content of a variable

Purge

Delete a global variable from the current directory

Remark: Purge only removes a variable from the current directory, not the enclosing directories. Since Recall will fetch variable values from enclosing directories, it is possible that 'X' Purge 'X' Recall will fetch a value for X from an enclosing directory. Use PurgeAll if you want to purge a variable including in enclosing directories.

PurgeAll

Delete a global variable from the current directory and enclosing directories.

Remark: If a variable with the same name exists in multiple enclosing directories, PurgeAll may purge multiple variables. Use Purge if you want to only purge a variable in the current directory.

CreateDirectory (CRDIR)

Create new directory

PurgeDirectory (PGDIR)

Purge entire directory tree

UpDirectory (UPDIR)

Change current directory to its parent

HomeDirectory (HOME)

Change current directory to HOME

DirectoryPath (PATH)

Get a path to the current directory

Variables (VARS)

List all visible variables in a directory

{ Variables... }

TypedVariables (TVARS)

List variables of a specific type

type{ Variables... } { types... }{ Variables... }

See the Type command for a list of types.

ORDER

Sort variables in a directory

QUOTEID

Add single quotes to a variable name

UNQUOTEID

Remove single quotes from a variable name

HIDEVAR

Hide a variable (make invisible)

UNHIDEVAR

Make a hidden variable visible

CLVAR

Purge all variables and empty subdirectories in current directory

LOCKVAR

Make variable read-only

UNLOCKVAR

Make variable read/write

RENAME

Change the name of a variable

SPROP

Store a property to a variable

RPROP

Recall a property of a variable

PACKDIR

Pack a directory in an editable object