pjs.setOccur()



This API sets the current position of a multiple-occurrence data structure.

Parameters

  1. Data structure - A Profound.js data structure field defined by pjs.define() with the "occurs" option.

  2. Occurrence number - The occurrence number to set to. The first occurrence is 1.

Exception Handling

An Error instance will be thrown if there are any problems setting the occurrence.

Example

Set/get multiple occurrence data structure
pjs.define("customer", {type: "data structure", qualified: true, occurs: 2, elements: { "number": {type: "integer", length: 10}, "name": {type: "char", length: 100, varying: true} }}); pjs.setOccur(customer, 1); customer.number = 123; customer.name = "ACME Corp."; pjs.setOccur(customer, 2); customer.number = 456; customer.name = "John Doe Institute of Anonymity"; /* Prints: Customer 123 = ACME Corp. Customer 456 = John Doe Institute of Anonymity */ for (var i = 1; i <= 2; i++) { pjs.setOccur(customer, i); console.log("Customer %d = %s", customer.number, customer.name); }

RPG Equivalent 

OCCUR, %OCCUR()