[ARCHIVE] Helper Functions Library – Powerful Add-on Functions

This article refers to an older version of the Library Elements. For information on the new Libraries, please take a look at this article.

General

The helper functions library contains many additional functions available in Soley Studio that are not part of GrGen. Currently library elements for graph operations (Graph elements), for actions concerning file paths and file names (Input/Output helpers), for processing date and time values (DateTime helpers), for string manipulations (String helpers), as well as for deleting elements (Delete rules) and merging elements (Merge rules) exist.

Library elements for Graph elements

There are following helper library elements available for both nodes and edges:

  • getNodeClass/getEdgeclass:This function returns a node’s  or edge’s full class name as a string in the output window. You can use this function within a rule or sequence.
  • isNodeofClass/isEdgeofClass: This function returns true in the output pad if a node/edge is of a specified class. You can use this function within a rule or sequence.
  • getNodeAttribute/ getEdgeAttribute:This function returns attribute’s value as object in the output pad. You can use this function within a rule or sequence.
  • areNodeAttributesEqual/areEdgeAttributesEqual: This function returns true if the specified attributes of two nodes are equal. You can use this function within a rule or sequence.

Library elements for Input/Output actions

There are following helper library elements available for files and projects:

For project paths:

  • _io_getProjectPath: This function returns a full path to the project’s folder.
    You can use this function within a rule or sequence.
  • _io_combineIntoPath: This function combines two strings into a full path and returns it. You can call this function within a rule or sequence.
  • _io_getProjectFullPath: This function returns a full path to a file or a folder relative to the project. You can call this function within a rule or sequence.

For files (see this article for an example):

  • _io_openFile: This function opens a file and returns it as an object. If the file does not exist, it will create a new one. You can call this function within a rule or sequence.
  • _io_readFileText: This function opens a file, reads its content, closes the file and returns the whole content as a single string. You can call this function within a rule or sequence.
  • _io_readFileLines: This function opens a file, reads its content, closes the file and returns the content as an array of strings (a string for each line).You can call this function within a rule or sequence.
  • _io_closeFile: This procedure closes a file that was opened before.
  • _io_writeFile: This procedure writes text to an open file. In comparison to io_writeTextToFile, it requires the opening of the file before, and its closing after.
    It is better for situations in which you have to write multiple times on the same file (io_writeTextToFile yould open and close the file at every new adding).
  • _io_writeLineFile: This procedure writes a line to a file and appends a newline at the end. It is similar to _io_writeFile, only the text is written on the same line as the existing text but on a new line.
  • _io_appendTextToFile: This procedure opens a file given a specified path, appends the text at the end of it and closes it. If the file does not exist, then it creates a new one.
  • _io_writeTextToFile: This procedure opens a file given a specified path, writes the text to it and closes it. If the file does not exist, it creates a new one. If it does, it overwrites it.

Library elements for DateTime

There are following helper library elements available for dealing with date formated data:

  • _dt_toString: This function returns a DateTime value as a string according to the format “MM-dd-yyyy HH:mm:ss”.
  • _dt_compare: This function compares two DateTime values represented as doubles. It returns an int result based on the comparison.
  • _dt_getNow: This function returns the current time as double.

Library elements for Strings

There are following helper library elements available for string manipulation:

  • _str_toDateTime: This function converts a string to a DateTime according to the format “MM-dd-yyyy HH:mm:ss”.
  • _str_isNullorEmpty: This function returns true if a string is null or empty or false otherwise.
  • _str_format: Converts the value of objects to strings based on the formats specified and inserts them into another string.
  • _str_trim: Removes all whitespace characters (space, newline, tab) from the beginning and end of the given string.

Library elements for deleting nodes/edges

There are following helper library elements available for deleting nodes or edges:

  • deleteNodeByClass/deleteEdgebyClass: Deletes a node/edge if it is of the specified class.
  • deleteIsolatedNode: Deletes a node if it has no incident edges.
  • deleteIsolatedNodeByClass: Deletes a node if it has no incident edges and is of the specified class.
  • deleteDuplicatedEdge: Deletes an edge if there is another one with the same source and target nodes.
  • deleteDuplicatedEdgeByClass: Deletes an edge if there is another one with the same source and target nodes and it is of the specified class.

Library elements for merging nodes

There are following helper library elements available for merging nodes:

  • mergeNodes: Merges two nodes if they are of the same class and have the specified attribute equal.

Further Information

If these functions do not fit your needs, you can have a look at the Global Function section of the Soley Help Center.

Was this article helpful?

Related Articles