pjs.moveLeft()

pjs.moveLeft()

Description

pjs.moveLeft() moves a value from one field into another, left adjusted, without any type checking. It has the same behavior as pjs.move() with the adjust left parameter always set to true.

Parameters

  1. Source - The field or value the data is taken from.

  2. Target - The field the data is moved into.

  3. Source date/time/timestamp format (optional) - The format used to render a date, time, or timestamp source before it is moved, for example *ISO or *USA.

  4. Pad (optional) - If passed as true, the target field is cleared before the move.

Examples

Example 1: Concatenated Value to Character

This example moves the result of a concatenation into a character field.

// Purpose: build a full name by moving a concatenated value into a field. pjs.define("Name", { type: 'char', length: 3, initValue: 'MR.' }); pjs.define("First", { type: 'char', length: 6, initValue: ' SMITH' }); pjs.define("Result", { type: 'char', length: 9 }); // Name + First is evaluated first, producing the 9-character value 'MR. SMITH'. pjs.moveLeft(Name + First, Result); return Result; // "MR. SMITH"

Example 2: Character to Character

This example shows which bytes of the target are preserved when the source is shorter than the target.

// Purpose: show that MOVEL keeps the target's rightmost bytes. pjs.define("source1", { type: 'char', length: 5, initValue: 'ABCDE' }); pjs.define("target1", { type: 'char', length: 10, initValue: 'abcdefghij' }); // The 5 source bytes overwrite the 5 leftmost bytes of the target. pjs.moveLeft(source1, target1); return target1; // "ABCDEfghij" -- the target's last 5 bytes are preserved.

Example 3: Decimal to Character

This example moves a numeric value into a character field, left adjusted.

// Purpose: move a numeric value into a character field, left adjusted. pjs.define("source1", { type: 'decimal', length: 5, decimals: 0, initValue: 12345 }); pjs.define("target1", { type: 'char', length: 10, initValue: 'abcdefghij' }); // The numeric digits are written into the leftmost bytes of the target. pjs.moveLeft(source1, target1); return target1; // "12345fghij"

RPG Equivalent

MOVEL


Related Pages