Skip to main content

##function

Evaluates an ObjectScript function at compile time.

Description

This macro preprocessor function evaluates an ObjectScript function at compile time. It has the form

##function(content)

where content is an ObjectScript function and can be user-defined. ##function replaces ##function(content) with the returned value from the function.

The following example returns the value from an ObjectScript function:

#define alphalen ##function($LENGTH("abcdefghijklmnopqrstuvwxyz"))
   WRITE $$$alphalen

In the following example, suppose there is a user-defined function in the GetCurrentTime.mac file:

Tag1()
 KILL ^x
 SET ^x = """" _ $Horolog _ """"
 QUIT ^x

It is then possible to invoke this code in a separate routine, called ShowTimeStamps.mac, as follows:

Tag2
#define CompiletimeTimeStamp ##function($$Tag1^GetCurrentTime())
#define RuntimeTimeStamp $$Tag1^GetCurrentTime()
 SET x=$$$CompiletimeTimeStamp
 WRITE x,!
 SET y=$$$RuntimeTimeStamp
 WRITE y,! 

The output of this at the Terminal is something like:

USER>d ^ShowTimeStamps
64797,43570
"64797,53807"

USER>

where the first line of output is the value of $Horolog at compile time and the second line is the value of $Horolog at runtime. (The first line of output is not quoted and the second line is quoted because x substitutes a quoted string for its value, so there are no quotes displayed in the Terminal, while y prints the quoted string directly to the Terminal.)

Note:

It is the responsibility of the application programmer to make sure that the return value of the ##function call makes both semantic and syntactic sense, given the context of the call.

##function Nesting

InterSystems IRIS supports nesting within a ##function. ##function can nest the following macro functions: ##BeginLit...##EndLit, ##function, ##lit, ##quote, ##expression, ##SafeExpression, ##stripq, and ##unique, ##this

Purpose of this instance: Draft documentation
DocReleaseID: HealthConnect2025.1
Content loaded from:
/staging/learning/iris-doc/2025.1.x/doc/cache/en-us/src/
/staging/learning/iris-doc/2025.1.x/doc/ensemble/en-us/src/
/staging/learning/iris-doc/2025.1.x/doc/healthconnect/en-us/src/
/staging/learning/iris-doc/2025.1.x/doc/healthcommon/en-us/src/
/staging/learning/iris-doc/2025.1.x/doc/security/en-us/src/
Excluded items: AADAN, ABIT, ACLOUD, AFL_adonet, AFL_ecp, AFL_icm, AFL_jdbc, AFL_netxep, AFL_sharding, AFL_xep, APMML, APOWER, ARGATEWAY, AWEBSOCKETS, AWSGI, BJAVA, BJAVNAT, BJAVPER, BJAVXEP, BJSNAT, BNET, BNETNAT, BNETODBC, BNETXEP, BPYNAT, BSPK, BTPI, BXCI, GAUTOML, GCONV, GCSP, GICM, GIKNOW, GIML, GISQ, GISR, GSCF, GSQLSRCH, GTSQ, GUIMA, PAGE_activex, PAGE_administration, PAGE_apimgr, PAGE_appdev_ides, PAGE_bi, PAGE_cachedirect, PAGE_data_migration, PAGE_data_science, PAGE_deployment, PAGE_deployment_configuration, PAGE_deployment_containers, PAGE_deployment_icm, PAGE_deployment_iko, PAGE_deployment_install, PAGE_dotnet, PAGE_dotnet_native, PAGE_dsvr, PAGE_embedded_language_development, PAGE_epython, PAGE_external_language_development, PAGE_interop, PAGE_interop_lifecycle, PAGE_interop_vdoc, PAGE_interoperability, PAGE_java, PAGE_java_jdbc, PAGE_java_native, PAGE_machine_learning, PAGE_monitoring, PAGE_multimodel, PAGE_multimodel_multidimensional, PAGE_multimodel_object, PAGE_multivalue, PAGE_native, PAGE_nodejs_native, PAGE_objectscript, PAGE_objectscript_ides, PAGE_odbc, PAGE_platform_arch_design, PAGE_pygate, PAGE_python, PAGE_python_native, PAGE_reports, PAGE_scalability, PAGE_security_authentication, PAGE_security_authorization, PAGE_studio, PAGE_zen, PAGE_zenmojo, PAGE_zenreports
FeedbackOpens in a new tab