TutorialGetting Started with MacrosMacro EditorUser InterfaceMenus and ToolbarEditing Macro StatementsExpression EditorMacro DebuggingHow ToUsing variablesFinding and modifying objectsCreating new page contentAsking for user inputStoring persistent dataSorting objectsSample MacrosConceptsExpressionsObjectsPropertiesVariablesData TypesArraysFunctionsLiteralsOperatorsComments |
Last updated on: February 06, 2021
Also available as a single HTML file Onetastic Macro Documentation > Concepts > Functions FunctionsFunctions 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 objects, manipulate strings, dates, arrays, create and display dialog boxes and control the macro execution. 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 FunctionsYou 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 takes a page and adds the images in this page in the byref parameters
// It returns a Bool indicating whether it found any images or not
Function GetImagesInPage($page, byref $imagesInOutline, byref $imagesOnPage)
$images = QueryObjects("Image", $page)
![]() ![]() ![]() // Get images in the current page
$imagesInOutline = Array()
$imagesOnPage = Array()
![]() |
ReferenceStatementsForEachIfElseWhileExpressionCommentBreakContinueReturnHierarchy ObjectsNotebookRootNotebookSectionGroupSectionPagePage ObjectsTitleOutlineTableColumnRowCellParagraphTextImageEmbeddedFileTagOther ObjectsDialogBoxFunctionsArray FunctionsColor FunctionsData Store FunctionsDate/Time FunctionsDialog Box FunctionsMacro Execution FunctionsObject FunctionsString Functions |