# `PARSE$` — `PUT`

## Contents

- `PARSE$` — Parses a filename
- `PAUSE` — Waits for a length of time
- `PEEKB` — Reads a short integer from a byte of memory
- `PEEKW` — Reads an integer from memory
- `PEEKL` — Reads a long integer from memory
- `PEEKF` — Reads a floating-point value from memory
- `PEEK$` — Reads a string from memory
- `PI` — Returns the value of PI
- `POINTERFILTER` — Sets the pointer event mask
- `POKEB` — Stores a short integer in a byte of memory
- `POKEW` — Stores an integer in memory
- `POKEL` — Stores a long integer in memory
- `POKEF` — Stores a floating-point value in memory
- `POKE$` — Stores a string in memory
- `POS` — Gets the position in the current view
- `POSITION` — Sets the position in the current view
- `PRINT` — Displays a list of expressions
- `PUT` — Writes changes into a database

## `PARSE$` — Parses a filename

Usage: `p$=PARSE$(f$,rel$,var off%())`

Returns a full file specification from the filename `f$`, filling in any missing information from `rel$`.

The offsets to the filename components in the returned string is returned in `off%()` which must be declared with at least 6 integers. Index values for `off%()` are:

`KParseAOffFSys%` | 1 | Filing system name offset.
`KParseAOffDev%` | 2 | Device name offset.
`KParseAOffPath%` | 3 | Path offset.
`KParseAOffFilename%` | 4 | Filename offset.
`KParseAOffExt%` | 5 | File extension offset.
`KParseAOffWild%` | 6 | Flags for wildcards in returned string. See below.

The flag values in `offset%(KParseAOffWild%)` are:

`KParseWildNone%` | 0 | No wildcards.
`KParseWildFilename$` | 1 | Wildcard in filename.
`KParseWildExt$` | 2 | Wildcard in file extension.
`KParseWildBoth$` | 3 | Wildcard in both.

These constants are supplied in Const.oph.

If `rel$` is not itself a complete file specification, the current filing system, device and/or path are used as necessary to fill in the missing parts.

`f$` and `rel$` should be separate strings.

        p$=PARSE$("NEW","C:\Documents\*.MBM",x%())

sets `p$` to C`:\Documents\NEW.MBM` and `x%()` to `(1,1,3,14,17,0)`.

## `PAUSE` — Waits for a length of time

Usage: `PAUSE x%`

Pauses the program for a certain time, depending on the value of `x%`:

0 | waits for a key to be pressed
+ve | pauses for `x%` twentieths of a second
-ve | pauses for `x%` twentieths of a second or until a key is pressed

So `PAUSE 100` would make the program pause for 100/20 = 5 seconds, and `PAUSE -100` would make the program pause for 5 seconds or until a key is pressed.

If `x%` is less than or equal to 0, a `GET`, `GET$`, `KEY` or `KEY$` will return the key press which terminated the pause. If you are not interested in this keypress, but in the one which follows it, clear the buffer after the `PAUSE` with a single `KEY` function: `PAUSE -10 :KEY`

You should be especially careful about this if `x%` is negative, since then you cannot tell whether the pause was terminated by a keypress or by the time running out.

`PAUSE` should not be used in conjunction with `GETEVENT` or `GETEVENT32` because events are discarded by `PAUSE`.

## `PEEKB` — Reads a short integer from a byte of memory

        p%=PEEKB(x&)

The PEEK functions find the values stored in specific bytes. `PEEKB` returns the integer value of the byte at address `x&`.

## `PEEKW` — Reads an integer from memory

        p%=PEEKW(x&)

Returns the integer at address `x&`.

## `PEEKL` — Reads a long integer from memory

        p&=PEEKL(x&)

Returns the long integer value at address `x&`.

## `PEEKF` — Reads a floating-point value from memory

        p=PEEKF(x&)

Returns the floating-point value at address `x&`.

## `PEEK$` — Reads a string from memory

        p$=PEEK$(x&)

Returns the string at address `x&`.

## `PI` — Returns the value of PI

Usage: `p=PI`

Returns the value of (3.14... ).

## `POINTERFILTER` — Sets the pointer event mask

Usage:`POINTERFILTER filter%,mask%`

Filters pointer events in the current window out or back in. Add the following flags together to achieve the desired `filter%` and `mask%`:

| $0 | None.
`KPointerFilterEnterExit%` | $1 | Enter/exit.
`KPointerFilterMove%` | $2 | Move.
`KPointerFilterDrag%` | $4 | Drag.

These constants are supplied in Const.oph.

The bits set in `filter%` specify the settings to be used, 1 to filter out the event and 0 to remove the filter. Only those bits set in `mask%` will be used for filtering. This allows the current setting of a particular bit to be left unchanged if that bit is zero in the mask. (i.e. `mask%` dictates what to change and `filter%` specifies the setting to which it should be changed). For example,

        mask% = KPointerFilterEnterExit% + KPointerFilterDrag%
        REM     allows enter/exit and drag settings to be changed
        POINTERFILTER KPointerFilterEnterExit%, mask%
        REM filters out enter/exit, but not dragging
        ...
        POINTERFILTER KPointerFilterDrag%, mask%
        REM filters out drag and reinstates enter/exit

Initially the events are not filtered out.

See also `GETEVENT32`, `GETEVENTA32`.

## `POKEB` — Stores a short integer in a byte of memory

        POKEB x&,y%

The POKE commands store values in specific bytes. `POKEB` stores the integer value `y%` (less than 256) in the single byte at address `x&`.

## `POKEW` — Stores an integer in memory

        POKEW x&,y%

Stores the integer `y%` across two consecutive bytes, with the least significant byte in the lower address, that is `x&`.

## `POKEL` — Stores a long integer in memory

        POKEL x&,y&

Stores the long-integer `y&` in bytes starting at address `x&`.

## `POKEF` — Stores a floating-point value in memory

        POKEF x&,y

Stores the floating-point value `y` in bytes starting at address `x&`.

## `POKE$` — Stores a string in memory

        POKE$ x&,y$

Stores the string `y$` in bytes starting at address `x&`.

Use `ADDR` to find out the address of your declared variables.

## `POS` — Gets the position in the current view

Usage: `p%=POS`

Returns the number of the current record in the current view. `POS` (and `POSITION`) exist mainly for compatibility with older versions of OPL and you are advised to use bookmarks instead.

A file has no limit on the number of records. However, integers can only be in the range -32768 to +32767. Record numbers above 32767 are therefore returned like this:

record value | returned by POS
32767 | 32767
32768 | 32768
32769 | 32767
32770 | 32766
... | ...
65534 | 2

To display record numbers, you can use this check:

        IF POS<0
              PRINT 65536+POS
        ELSE
              PRINT POS
        ENDIF

N.B. the number of the current record may be greater than or equal to 65535 and hence values may need to be truncated to fit into `p%`, giving inaccurate results. You are particularly advised to use bookmarks when dealing with a large number of records. Note, however, that the value returned by `POS` can become inaccurate if used in conjunction with bookmarks and multiple views on a table. Accuracy can be restored by using `FIRST` or `LAST` on the current view.

See `BOOKMARK`, `GOTOMARK`, `KILLMARK`.

## `POSITION` — Sets the position in the current view

Usage: `POSITION x%`

Makes record number `x%` the current record in the current view. By using bookmarks and editing the same table via different views, positional accuracy can be lost and `POSITION x%` could access the wrong record. Accuracy can be restored by using `FIRST` or `LAST` on the current view.

`POSITION` (and `POS`) exist mainly for compatibility with older versions of OPL and you are advised to use bookmarks instead.

See `BOOKMARK`, `GOTOMARK`, `KILLMARK`.

## `PRINT` — Displays a list of expressions

Usage: `PRINT list of expressions`

Displays a list of expressions on the screen. The list can be punctuated in one of these ways:

If items to be displayed are separated by commas, there is a space between them when displayed.

If they are separated by semicolons, there are no spaces.

Each `PRINT` statement starts a new line, unless the preceding `PRINT` ended with a semicolon or comma.

There can be as many items as you like in this list. A single `PRINT` on its own just moves to the next line.

Examples: On 1st January 1997,

code | display
`PRINT "TODAY is", :PRINT DAY;".";MONTH;".";YEAR` | `TODAY is 1.1.1997`
`PRINT 1` | `1`
`PRINT "Hello"` | `Hello`
`PRINT "Number",1` | `Number 1`

See also `LPRINT`, `gUPDATE`, `gPRINT`, `gPRINTB`, `gPRINTCLIP`, `gXPRINT`.

## `PUT` — Writes changes into a database

Usage: `PUT`

Marks the end of a database’s `INSERT` or `MODIFY` phase and makes the changes permanent.

See `INSERT`, `MODIFY`, `CANCEL`.