ZxApp IT Users Guide

5.8.1 Defining Your Own Functions

Introduction

You can define your own ad-hoc functions right within the body of your WYSIWYG text.  For example, we could define a "Hello World" function as follows;


      function sayHello(name) returns message

      {

            message="Hello "+name;

      }


Subsequently, we would use this function by typing 'sayHello("Kurt")=[Control-Space]', which would yield 'sayHello("Kurt")=Hello Kurt'.


Nesting Ad-hoc Functions


We can nest ad-hoc functions within subnodes.  To do this, we simply create a subnode and define a function in it.  For example, if the sayHello() function was defined in a subnode named 'my functions, we would use it by typing 'myFunctions.sayHello("Kurt")=[Control-Space]'.


This is going to require a little explaining.  First, case is irrelevant, so we could have typed it as 'myfunctions.sayHello("Kurt")=[Control-Space]'.  Next, you might have noticed that the space was removed from the node name; 'my functions' became 'myfunctions'.  This is called "mangling" your variable names.  Since spaces cannot be used within an identifier, ZxApp IT would not understand the meaning of 'my functions.sayHello("Kurt")=[Control-Space]'.  It would see the identifier 'functions' as the beginning of the expression and begin evaluation there.  This is why ZxApp IT was designed to understand "mangled" variable names in certain contexts.

 


Copyright 2009 ZipXap Technology, LLC. All Rights Reserved.