Onetastic Macro Documentation >
>
Functions Functions
Functions in macros are similar to the same concept in other programming languages. They
take one or more parameters and return a single value (or no value). They can be used to
retrieve , manipulate , ,
, create and display and
.
Following is an example usage of String_Length and GetCurrentPage functions
to obtain the length of the title of the current page:
$length = String_Length(GetCurrentPage().name)
Below is the list of all available built-in functions:
User Defined Functions
You can also define your own functions with parameters and return value. You can decide whether
the paremeters are passed by reference or by value using the byref keyword.
For pass-by-value, a copy of the argument is passed as the parameter. For pass-by-reference,
a reference to the argument is passed and the function can modify the caller's argument.
Objects are always passed by reference regardless of whether the parameter was decorated
by byref or not.
function GetImagesInPage($page, byref $imagesInOutline, byref $imagesOnPage)
$images = QueryObjects("Image", $page)
foreach ($image in $images)
if (GetParentOfType($image, "Page", $parentPage))
Array_PushBack($imagesInOutline, $image)
else
Array_PushBack($imagesOnPage, $image)
return Array_Length($images) > 0
$imagesInOutline = Array()
$imagesOnPage = Array()
if (GetImagesInPage(GetCurrentPage(), $imagesInOutline, $imagesOnPage))
|