...
Element name | Element type | Description |
---|
type | String | There are the following types available in Profound.js - packed decimal
- decimal
- integer
- unsigned integer
- char
- boolean
- date
- time
- timestamp
- pointer
- data-structure
Some config elements only apply to certain types. |
length | Number | Required on all types other than |
decimals | Number | Required on types |
varying | Boolean | Available to char type. |
initValue | String/Number/Boolean | Available to all data types. |
dim | Number | Available to all data types. Using dim makes your field into an array. Arrays are 1-indexed. |
orderby | String | Available to all types when dim element is used. Either of these values are required: |
elements | Object | Required when using data-structure type. Read about data-structures below. |
qualified | Boolean | Available when using data-structure type. |
special | String | ??? |
Examples
Example 1: packed decimal
Code Block |
---|
|
pjs.define("Num", { type: 'packed decimal', length: 3, decimals: 2 });
Num = 5; |
Example 2: date with initValue
Code Block |
---|
|
pjs.define("loandate", { type: 'date', initValue: pjs.date('2000-01-01') }); |
Example 3: char field with pointer to that field
Code Block |
---|
|
pjs.define("stg", { type: 'char', length: 4 });
pjs.define("ptr", { type: 'pointer', initValue: pjs.getBuffer("stg") }); |
Example 4: char field array with initValue
This does mean that every element in this array will be initilized with the initValue.
Code Block |
---|
|
pjs.define("arr", { type: 'char', length: 10, dim: 3, initValue: '0123456789' }); |
Data-structures
When you declare a field of data-structure type, this means you need to provide an 'elements' object. Each key in this object will be the name of the subfield and the value of this key will be another config element. If a data-structure is qualified, the data-structure will act similar to a JavaScript object.
Example 5: data-structure with two subfields (non-qualified)
Code Block |
---|
|
pjs.define("someDS", { type: 'data structure', elements: {
"Field1": { type: 'char', length: 10, initValue: '1' },
"Field2": { type: 'char', length: 10 }
}});
Field2 = '2'; |
Example 6: data-structure array, qualified and two subfields
Code Block |
---|
|
pjs.define("dsarr", { type: 'data structure', qualified: true, dim: 2, elements: {
"field1": { type: 'char', length: 1 },
"field2": { type: 'char', length: 1 }
}});
dsarr[1].field1 = '1';
dsarr[1].field2 = '2';
dsarr[2].field1 = '3';
dsarr[2].field2 = '4'; |