MiniM. Saving time.


| About | Download | Tools | Knowledge Base | How to Buy |

MiniM Overview

Getting Started

Download

Documentation

Tools

Cache Tools

GT.M Tools

Knowledge Base

FAQ

Contacts

Copyrights

MiniM Knowledge Base | Sep 24, 2010

How to Specify Routine's or Global's Database.

Sometime developer must specify global or routine name placed not in current database of process. This article describe how to do this in MUMPS language.

MUMPS language uses convention if database of global or routine does not specified directly, process must use current database. So, processes executed the same code calls different globals and routines. If it is required to use specified database, different from current database of the process, the global's or routine's database must be specified directly, before the global's or routine's name.

Direct specification of database name for the global:

^|dbname|gloname(subscripts,...)

Direct specification of database name for the routine:

^|dbname|rouname(arguments,...)

Name of the database must be specified as an evaluateble expression. Expression can have any complexity to evaluate, and can contain constants, operators, function calls or indirections. Example how to use constant as a database name:

s val=^|"TEMP"|gloname(subscripts,...)
d ^|"TEMP"|rouname(arguments,...)

Example how to use expression with operators as a database name:

s a="TE",b="MP"
s val=^|a_b|gloname(subscripts,...)
d ^|a_b|rouname(arguments,...)

Example how to use expression with indirection as a database name:

s curdb="TEMP"
s dbname=$na(curdb)
s val=^|@dbname|gloname(subscripts,...)
d ^|@dbname|rouname(arguments,...)

If database name specified, MiniM process does not change current database to specified for global or routine accessing.

MiniM Database Server also support convention of an empty string specified as a database name is equal to use current database. This convention allow to specify current database if database name evaluates as an expression.

Also MiniM Database Server support legacy database name notation with square brackets to allow port available routines:

s val=^[dbname]gloname(subscripts,...)
d ^[dbname]rouname(arguments,...)

To specify label, offset, database and routine name together the database name must be placed before the routine name:

d label+offset^|dbname|rouname

Programmer must understand that all evaluations in the MUMPS language executes in left-to-right order, or in order specified by the parenthesis, even if evaluates the database name for global or routine.

Eugene Karataev
support@minimdb.com


Copyright (C) Eugene Karataev
Info Support