# `LAST` — `LPRINT`

## Contents

- `LAST` — Positions to the last record
- `LCLOSE` — Closes the device opened with `LOPEN`
- `LEFT$` — Gets the leftmost characters of a string
- `LEN` — Length of a string
- `LENALLOC` — Gets the length of a previously allocated cell
- `LN` — Natural logarithm
- `LOADM` — Loads a translated OPL module
- `LOC` — Locates a sub-string within a string
- `LOCAL` — Declares procedure-local variables
- `LOCK` — Blocks system requests to change files or quit
- `LOG` — Logarithm
- `LOPEN` — Opens a device for printing
- `LOWER$` — Converts a string to lower case
- `LPRINT` — Prints a list to the device opened using `LOPEN`

## `LAST` — Positions to the last record

Usage:`LAST`

Positions to the last record in a view.

See filing.db.

## `LCLOSE` — Closes the device opened with `LOPEN`

Usage: `LCLOSE`

Closes the device opened with `LOPEN`. The device is also closed automatically when a program ends.

## `LEFT$` — Gets the leftmost characters of a string

Usage: `b$=LEFT$(a$,x%)`

Returns the leftmost `x%` characters from the string `a$`.

For example if `n$` has the value `Charles`, then `b$=LEFT$(n$,3)` assigns `Cha` to `b$`.

## `LEN` — Length of a string

Usage: `a%=LEN(a$)`

Returns the number of characters in `a$`.

E.g. if `a$` has the value `34 Kopechnie Drive` then `LEN(a$)` returns `18`.

You might use this function to check that a data file string field is not empty before displaying:

        IF LEN(A.client$)
              PRINT A.client$
        ENDIF

## `LENALLOC` — Gets the length of a previously allocated cell

Usage: `len&=LENALLOC(pcell&)`

Returns the length of the previously allocated cell at `pcell&`. An error will be raised if the cell address argument is not in the range known by the heap.

See also `SETFLAGS` if you require a 64K memory limit to be enforced. If the flag is set to restrict the limit, `len&` is guaranteed to fit into an integer.

ARM

Cells are allocated lengths that are the smallest multiple of four greater than the size requested because the ARM processor requires a four-byte word alignment for its memory allocation. The ARM processor is used in the Psion Series 5 and other EPOC devices.

## `LN` — Natural logarithm

Usage: `a=LN(x)`

Returns the natural (base e) logarithm of `x`.

Use `LOG` to return the base 10 log of a number.

## `LOADM` — Loads a translated OPL module

Usage: `LOADM module$`

Loads a translated OPL module so that procedures in that module can be called. Until a module is loaded with `LOADM`, calls to procedures in that module will give an error.

`module$` is a string containing the name of the module. Specify the full file name only where necessary.

Example: `LOADM "MODUL2"`

Up to 8 modules can be in memory at any one time, including the top level module; if you try to `LOADM` a ninth module, you get an error. Use `UNLOADM` to remove a module from memory so that you can load a different one.

By default, `LOADM` always uses the folder of the top level module. It is not affected by the `SETPATH` command.

## `LOC` — Locates a sub-string within a string

Usage: `a%=LOC(a$,b$)`

Returns an integer showing the position in `a$` where `b$` occurs, or zero if `b$` doesn’t occur in `a$`. The search matches upper and lower case.

Example: `LOC("STANDING","AND")` would return the value `3` because the substring `AND` starts at the third character of the string `STANDING`.

## `LOCAL` — Declares procedure-local variables

Usage: `LOCAL variables`

Used to declare variables which can be referenced only in the current procedure. Other procedures may use the same variable names to create new variables. Use `GLOBAL` to declare variables common to all called procedures.

The variables may be of 4 types, depending on the symbol they end with:

- Variable names not ending with `$`, `%`, `&` or `()` are floating-point variables, for example `price`, `x`
- Those ending with a `%` are integer variables, for example `x%`, `sales92%`
- Those ending with an `&` are long integer variables, for example `x&`, `sales92&`.
- Those ending with a `$` are string variables. String variable names must be followed by the maximum length of the string in brackets, for example `names$(12)`, `a$(3)`

Array variables have a number immediately following them in brackets which specifies the number of elements in the array. Array variables may be of any type, for example: `x(6),y%(5),f$(5,12),z&(3)`

When declaring string arrays, you must give two numbers in the brackets. The first declares the number of elements, the second declares their maximum length. For example `surname$(5,8)` declares five elements, each up to 8 characters long.

Variable names may be any combination of up to 32 numbers, alphabetic letters and the underscore character. They must start with a letter or an underscore. The length includes the `%`, `&` or `$` sign, but not the `()` in string and array variables.

More than one `GLOBAL` or `LOCAL` statement may be used, but they must be on separate lines, immediately after the procedure name.

See also `GLOBAL`, `CONST` and Constants and variables — Storing values for later use.

## `LOCK` — Blocks system requests to change files or quit

Usage: `LOCK ON
`or `LOCK OFF`

Marks an application as locked or unlocked. When an app is locked with `LOCK ON`, the System screen will not send it events to change files or quit.

If, for example, you move to the task list or the document name in the System screen try to stop that running app by using the ‘Close file’ button or Ctrl+E, a message will appear, indicating that the app cannot close down at that moment.

You should use `LOCK ON` if your application uses a command, such as `EDIT`, `MENU` or `DIALOG`, which accesses the keyboard. You might also use it when the app is about to go busy for a considerable length of time, or at any other point where a clean exit is not possible. Do not forget to use `LOCK OFF` as soon as possible afterwards.

An application is initially unlocked.

## `LOG` — Logarithm

Usage: `a=LOG(x)`

Returns the base 10 logarithm of `x`.

Use `LN` to find the base e (natural) log.

## `LOPEN` — Opens a device for printing

Usage: `LOPEN device$`

Opens the device to which `LPRINT`s are to be sent.

No `LPRINTs` can be sent until a device has been opened with `LOPEN`.

You can open any of these devices:

- The serial port, with `LOPEN "TTY:A"`
- A file on the EPOC device. Any existing file of the name given will be overwritten when you print to it.

Only one device may be open at any one time. Use `LCLOSE` to close the device. `LOPEN`ned devices also close automatically when a program finishes running.

See also: Serial ports and printing.

## `LOWER$` — Converts a string to lower case

Usage: `b$=LOWER$(a$)`

Converts any upper case characters in the string `a$` to lower case and returns the completely lower case string.

E.g. if `a$="CLARKE"`, `LOWER$(a$)` returns the string `"clarke"`

Use `UPPER$` to convert a string to upper case.

## `LPRINT` — Prints a list to the device opened using `LOPEN`

Usage: `LPRINT` list of expressions

Prints a list of items, in the same way as `PRINT`, except that the data is sent to the device most recently opened with `LOPEN`.

The expressions may be quoted strings, variables, or the evaluated results of expressions. The punctuation of the `LPRINT` statement (commas, semicolons and new lines) determines the layout of the printed text, in the same way as `PRINT` statements.

If no device has been opened with `LOPEN` you will get an error.

See `PRINT` for displaying to the screen.

See `LOPEN` for opening a device for `LPRINT`.

See also `Printer.opx` — Printer and text handling for details of more advanced printing features.