Article
· Mar 21 2m read

Left Side Functions in ObjectScript

In ObjectScript you have a wide collection of functions that return some value
typically:

set variable = $somefunction(param1,param2, ...)

There is nothing special about that.
But there is a set of functions that I classify as LEFT SIDED 
The specialty of them is that you can use them also on the left of the equal operator 
as a target in the SET command:

set $somefunction(param1,param2, ...) = value

The reason to raise that subject is that with IRIS 2024.1 there is after may years  a "new kid on this block"

$VECTOR()

Assigns, returns, and deletes vector data at specified positions
especially
set $VECTOR(MyVector , position , type) = value

I do not want to elaborate on the details. The documentation is really complete.
There are also 3 other new vector-related right sided functions 
$VECTORDEFINED (),  $VECTOROP(), $ISVECTOR()  
You find the description following the links.

If you follow the examples in the documentation, you see that the new related
SQL Function TO_VECTOR () does pretty much the same in SQL notation
(actually it's not visible in InterSystems SQL Reference )

As a reminder / overview a list of the traditional left side functions:

  • $BIT – Returns and or sets the bit value of a specified position in a bitstring.
  • $EXTRACT – Extracts a substring from a character string by position, or replaces a substring by position.
  • $LIST – Returns or replaces elements in a list.
  • $PIECE – Returns or replaces a substring, using a delimiter.
  • $WEXTRACT – Extracts a substring from a character string by position, or replaces a substring by position, recognizing surrogate pairs.

It's a short list but can be highly efficient in some cases to avoid duplicated content and confusing manipulations.

Discussion (3)3
Log in or sign up to continue