Querying global objects
Query criteria that are not preceded by an object name are assumed to belong to the global object. For example, the expression method(2)
assumes that global.method(2)
is called.
The global object type provides functions and constants that are common in mathematics, 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
|
• |
|
The query criteria for global objects are available directly and do not require
qualification. For example, specifying only pi executes global.pi.
|
Global objects support the following query criteria:
Query criteria
|
Description
|
Example and result
|
global.array([object, ...])
|
Creates an array of objects specified as parameters
|
array('a','b','c') .convert($item.repeat($index)).join(',')
Yields 'a,bb,ccc'
|
global.atan(double)
|
Returns the arctangent of the number
|
|
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.chr(int)
|
Returns a character by the specified Unicode character code
|
chr(65)
Yields 'A'
|
global.cos(double)
|
Returns the cosine of the number
|
|
global.double()
|
Returns the type definition of the double class
|
|
global.e()
|
Returns a double value of natural logarithm base
|
|
global.exp(double)
|
Returns the exponent of the number (e^x)
|
|
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')
Yields 'apple'
|
global.int()
|
Returns the type definition of the int class
|
|
global.log(double)
|
Returns the natural logarithm of the value
|
|
global.max(numeric, ...)
|
Returns the maximum value of the parameters
|
max(2,3,4,1,0,13,5)
Yields 13
|
global.min(numeric, ...)
|
Returns the minimum value of the parameters
|
min(2,3,4,1,0,13,5)
Yields 0
|
global.pi()
|
Returns a double value of pi
|
|
global.sin(double)
|
Returns the sine of the number
|
|
global.sqrt(double)
|
Returns the square root of the number
|
|
global.string()
|
Returns the type definition of the string class
|
|
global.tan(double)
|
Returns the tangent of the number
|
|
Global objects also support the following color-related query criteria:
Query criteria
|
Description
|
Example and result
|
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.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.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.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.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.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.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
|
You can include additional queries that filter the global properties of shapes on a page or layer.
To access the properties and methods of the current object, you must prepend the property name or method name with the at sign ( @
). Thus, @type
calls the Type property of the current object for which the expression is evaluated.
• |
|
You can call an expression without specifying the current shape. However, in
this case, the @ operator is unavailable.
|
Global queries can return values of any of the other supported object types (see Understanding the available query criteria).
Calling macro functions
You can include queries that call macro functions. The vba property of the VBA global object provides access to public macro functions through the following syntax:
vba.Project.Module.Function(parameters) |
For example, you can add the following VBA function to GlobalMacros>Module1:
Public Function Sum(ByVal x As Double, ByVal y As Double) As Double |
You can then call this function from a query such as the following, yielding the result 5:
MsgBox Application.Evaluate("vba.GlobalMacros.Module1.Sum(2, 3)") |
Only public functions in code modules can be called in this way. Private functions, functions in class modules or form modules, and subroutines cannot be called from queries.
Copyright 2013 Corel Corporation. All rights reserved.