Hits since 2023-09-16 01:38:03:
550

Rosevear Software



Libraries:

SAM Supports Libraries

One library, SAM.tool, comes pre-installed.  The user may install as many additional libraries as desired.  These may come from me or from anyone.  You may make your own.

It is important to understand that libraries are a convenience, and that is all.  They are abstractions which provide a consistent interface to menus.

SAM.tool, for example, is represented by the library $lib/tool.  The commands of the library can be added to the current command set by:

  • bound $lib/tool

and by variations on the above.  You may do this, and you should just to see what happens, although it is unlikely to have any real effect* if it is already referenced in the corresponding init file.

  • *Let's say that it is already referenced as I described, and you try it anyway.  You can observe this unlikely effect on PATH by following up with the use of shoparts PATH.  At most you may see a change in the order of directories in PATH.

    In addition to executables, the command set may also contain functions.  If the set of directories from which your qualified functions are derived contains functions with names that are not unique--generally not a good idea--then this sort of maneuver may change which of them are available in the command set by changing the order in they are defined.

Let me explain a little.  SAM can be started by begin in the root of SAM or by a symlink in a dual directory.  In either case the default bprofile, init and lib are the ones in the corresponding directory (either the root of SAM or the dual directory).  SAM refers to bprofile, init, and lib using $bprofile, $init, and $lib and thus makes sense of this.

To configure SAM so that a library is automatically added to the current commmand set when SAM is started, simply reference it in the corresponding init file.  The init in the distribution comes pre-configured with a reference to $lib/tool:

  • echo : $lib/tool final

To learn more about how SAM supports the use of libraries and about the SAM.tool library, please read the GUIDE which is included in the distribution.

Get a Library

Click on a library at the left to read about it or download it.

Unpack a Library

Make a directory for the library.  For example:

  • mkdir /tmp/handy

In the directory you made, unpack the library.  For example:

  • cd /tmp/handy
    tar -xvzf <path to downloads>/SAM.handy-0.tar.gz

Please see Unpacking SAM.

Use a Library

Please be careful.  You are fully responsible for your use of the SAM libraries, even if I have made huge and unforgivable errors.

Here is an example showing one way to do use the handy library after unpacking it as shown above.  From within a running SAM session:

  • bound $level /tmp/handy

The above makes all the commands of handy available.  (This includes any qualified function definitions that are in the library.)

To see the menu for the commands of handy:

  • menu /tmp/handy

Alternately, see above about how to "configure SAM so that a library is automatically added to the current commmand set when SAM is started".

Remember that you do not need to change your PATH to include the location of the library—SAM does that for you, and more!



© Joseph Rosevear
  |   Source touched: 2024-09-25 01:16:37