pjs.clear()

pjs.clear()

Description

pjs.clear() clears the contents of a field, an array, a data structure, or a record format, setting it to the default value for its data type. For example, clearing a character field sets it to blanks, and clearing a numeric field sets it to 0.

Parameters

  1. Field or record format name - The field, array, data structure, or record format to clear.

  2. options (optional Object) - Only needed when clearing a record format. The following properties are available:

    • all - Use when you need to clear all fields, even the input only fields.

    • nokey - Use when you want to clear all fields except for the key fields.

Examples

Example 1: Clearing a Character Field

pjs.define("s", { type: 'char', length: 3 }); s = '123'; // s is now '123' pjs.clear(s); // s is now ' '

Example 2: Clearing an Array

pjs.define("n", { type: 'integer', length: 5, decimals: 0, dim: 3 }); n[1] = 12334; // n is now 12334,0,0 pjs.clear(n); // n is now 0,0,0

Example 3: Clearing a Record Format on a Display

pjs.defineDisplay("display", "productd.json"); /*...*/ // Clear all fields, even the input only fields, of record format "main" for a display. // Displays do not have keys, so including nokey will have no effect. pjs.clear("main", { all: true });

Example 4: Clearing a Record Format on a Table

pjs.defineTable("productsp", { read: true, keyed: true }); /*...*/ // Clear non input only, non-key fields of record format "products" for a table. pjs.clear("products", { nokey: true }); // Clear all non-key fields of record format "products" for a table. pjs.clear("products", { all: true, nokey: true }); // Clear all fields of record format "products" for a table. pjs.clear("products", { all: true });

RPG Equivalent

CLEAR


Related Pages