What query methods are supported for global objects?
Identifiers not preceded by an object name are assumed to be methods of the global object. Consider the following expression:
The preceding expression assumes that global.method(2)
is called.
The global object provides common math functions and constants such as pi, e, sin, cos, min, and max.
pi
evaluates to 3.14159265358979.
sin(2)
evaluates to 0.909297426825682.
max(1, 2, 4, 3, 0)
evaluates to 4.
Global object methods are available directly and do not require any object qualification to call. For example, specifying only pi
executes the pi method of the global object
The following query methods are supported for global objects:
Method
|
Description
|
Example
|
Result
|
global.bool()
|
Returns the type definition of the bool class. Type definition is a special instance of the class that doesnt have the data associated with it. Only static methods (such as TypeName) can be called on type-definition objects.
|
|
|
global.int()
|
Returns the type definition of the int class
|
|
|
global.double()
|
Returns the type definition of the double class
|
|
|
global.string()
|
Returns the type definition of the string class
|
|
|
global.pi()
|
Returns a double value of pi
|
|
|
global.e()
|
Returns a double value of natural logarithm base
|
|
|
global.min(numeric, ...)
|
Returns the minimum value of the parameters
|
min(2,3,4,1,0,13,5)
|
0
|
global.max(numeric, ...)
|
Returns the maximum value of the parameters
|
max(2,3,4,1,0,13,5)
|
13
|
global.sqrt(double)
|
Returns the square root of the number
|
|
|
global.sin(double)
|
Returns the sine of the number
|
|
|
global.cos(double)
|
Returns the cosine of the number
|
|
|
global.tan(double)
|
Returns the tangent of the number
|
|
|
global.atan(double)
|
Returns the arctangent of the number
|
|
|
global.exp(double)
|
Returns the exponent of the number (e^x)
|
|
|
global.log(double)
|
Returns the natural logarithm of the value
|
|
|
global.iif(bool, expression, expression)
|
Acts as an inline if function. The first parameter is a Boolean expression. If the expression evaluates to True, then iif returns the value of the seconds parameter; otherwise, it returns the value of the third parameter.
|
iif('This is an apple'.contains('apple'), 'apple', 'orange')
|
'apple'
|
global.array([object, ...])
|
Creates an array of objects specified as parameters
|
array('a','b','c').convert($item.repeat($index)).join(',')
|
'a,bb,ccc'
|
global.chr(int)
|
Returns a character by the specified Unicode character code
|
chr(65)
|
'A'
|
You can perform additional queries that filter the global properties of shapes on a page or layer.
To access the methods and properties of the current object, you must prepend the method or property name with the at sign ( @
). Thus, @width
calls the width method of the current object for which the expression is evaluated.
Expressions can be called without specifying the current object. In this case, the @
operator is unavailable.
Global queries can return values of any of the other supported query object types (see the section What can be queried?).
The following query methods are also supported for global objects:
Method
|
Description
|
Example
|
Result
|
global.rgb(int, int, int)
|
Returns an RGB color with specified components
|
@fill.color = rgb(255,0,0)
|
Checks whether the shape has a red RGB fill
|
global.cmyk(int, int, int, int)
|
Returns a CMYK color with specified components
|
@colors.find(cmyk(0,0,0,100))
|
Finds shapes with a black CMYK color
|
global.cmy(int, int, int)
|
Returns a CMY color with specified components
|
@colors.find(cmy(0,0,0))
|
Finds shapes with a white CMY color
|
global.hsb(int, int, int)
|
Returns an HSB color with specified components
|
@fill.color.hsb = hsb(90,100,100)
|
Checks whether the shape has a (90, 100, 100) HSB fill
|
global.hls(int, int, int)
|
Returns an HLS color with specified components
|
@colors.find(hls(0,0,0))
|
Finds shapes with a (0,0,0) HLS fill
|
global.lab(double, int, int)
|
Returns a LAB color with specified components
|
@outline.color.lab = lab(100,127,127)
|
Checks whether the shape has a (100, 127, 127) LAB outline
|
global.yiq(int, int, int)
|
Returns a YIQ color with specified components
|
@colors.find(yiq(0,0,0))
|
Finds shapes with a (0,0,0) YIQ color
|
How can macro functions be called?
You can perform queries that call macro functions. The vba property of the VBA global object provides access to public macro functions through the following syntax:
For example, you can add the following VBA function to GlobalMacros>Module1:
You can then call this function from a query such as the following, yielding the result 5:
Only public functions in code modules can be called in this way. Private functions, functions in class or form modules, and subroutines cannot be called from queries.
Copyright 2007 Corel Corporation. All rights reserved.