N Code Function Definition
Home ] Up ] N Code Execution Model ] N Code Language ] N Code Data Types ] N Code Expressions ] N Code Statements ] N Code Variables and Scoping Rules ] N Code Filters ] [ N Code Function Definition ] N Code Tools ] N Code Triggers ]


N Code Function Definition

Declare functions using a simple syntax.

Example:

func foo {
echo( "hello world\n" );
}

Parameters are available to functions using a shell like notation, with $1 representing the first value, $2, the second, and so on. The special value '$#' represents the number of arguments. Function invocation syntax has already been seen; built in functions like echo are simply special cases of NFR function invocation.

Comma separated parameters are passed by value. For example: foo() => hello world [using the function foo defined above]

Functions

Built-in functions are available to every scope. They behave just like user defined functions. Parameters are passed by value.

  • alert: NFR code interface to the alert daemon.
  • display: dump the contents of the current packet to the current connection.
  • echo: echo the parameters to the current connection.
  • errno: return the numerical value of the parameter-error.
  • index: locates a string within a string.
  • listadd: adds another value to the list passed in. Returns a new list.
  • listlen: return the number of entries in the list.
  • lsort: list sort. Sorts elements in a list, and returns a new list.
  • luniq: create a list from a list, the new list will have duplicate entries removed.
  • match: accepts two parameters, used to compare a pattern to a string. create a list from a list, the new list will have duplicate entries removed.
  • pattern: return a pattern type that can then be used to compare with strings, or in the match bltin. The type passing into pattern is a string that is a `regex' style regular expression.
  • recorder: creates a recorder type. See section on recorders.
  • regcomp: synonym for pattern bltin.
  • regexec: synonym for match bltin.
  • strcasecmp: string comparison, without concerns for case matching.
  • strcat: concatenates all the parameters passed in.
  • strerror: returns a string, describing an error (similar to errno builtin)
  • strlen: returns the sum of the length of all parameters passed in.
  • sublist: similar to substr for lists.
  • substr: returns the substring of the string argument.
  • typeof: returns a string, describing the type of the passed in parameter.

Back ] Home ] Up ] Next ]