<script src="https://wiki.oceannetworks.ca/download/attachments/75170291/docs-client-libraries.js"></script>

These methods are included as convenience shortcuts for end users.

Summary

MethodDescription

Utility methods (collection, filename)

Prints collections in a format easier to read

Utility methods (dateString)

Formats the provided date string as ISO8601 UTC



print

Prints a collection to the console in a format easier to read. Can alternatively print to a text file if a filename is provided.

Used in the examples to print the results returned by other class methods.

Parameter

Type

Description

Example

collectionAny

Any collection, including scalar values, ^dictionaries and ^lists (i.e. those returned by other methods)


filenamestring

If present, the ^dictionary will be printed to a text file with this filename.

When not present, the dictionary is printed to the console.

Default value: None (prints to console)

'output.txt'

(parameters with an underline are required)


Examples of inputs & outputs



onc.print({
    'a': [1, 2, 3],
    'b': { 'c': True }
})



onc.print(struct(          ...
    'a', [1, 2, 3],        ...
    'b', struct('c', true) ...
));



onc$print(list(
    "a" = list(1, 2, 3),
    "b" = list( "c" = TRUE )
))





{
    "a": [
        1,
        2,
        3
    ],
    "b": {
        "c": true
    }
}

Note how lists are printed between square brackets ( [  ] ) and dictionaries are printed between curly brackets ( {   } ), one element per line, separated by commas.


struct(
    a: [
        1,
        2,
        3
    ]
    b: struct(
        c: true
    )
)

Note how vectors are printed between square brackets ( [  ] ), one element per line, separated by commas.

Structures are printed surrounded by the struct() function, one element per line, with every pair of key and value separated by a colon.


[
  a: [1, 2, 3],
  b: [
    c: TRUE
  ]
]

Note how lists and named lists are printed between square brackets ( [  ] ).

Elements in lists are printed separated by commas.

Elements in named lists are printed one element per line, separated by commas, with every pair of key and value separated by a colon.




formatUtc

Formats the provided date string as a ISO8601 UTC date string (the date format required by the API).

Provides an easy way to format dates to include as filters in "dateFrom" and "dateTo" fields.

Parameter

Type

Description

Example

dateStringstring

A string that represents a date & time in any of the formats described in the parser.parse() method. Most date formats work, including:

  • '2016-12-04'
  • '2016-Dec-04, 12:00:00'
  • '2016 Dec 04 03:00 PM'
  • 'now' (returns current UTC date & time)

Default value: 'now'

'2018-09-26, 12:00 PM'


Example: Print a UTC date formated as ISO8601



myDate = onc.formatUtc('2019-Sept-09 03:00 PM')
print(myDate)



myDate = onc.formatUtc('2019-Sept-09 03:00 PM');
disp(myDate);



myDate = onc$formatUtc("2019-Sept-09 03:00 PM")
cat(myDate)



The above code will output the UTC date in ISO8601 format, as expected for dates in filters provided to other class methods:

2019-09-09T15:00:00.000Z