HyperNext Studio > Getting Started

Function system


Hello, I want to know How can I create a 'function' (user-defined procedure) and create a 'plug-in' (plug-in procedure)?

Yes it is possible to create your own user-defined functions but they are clumsy to call compared to a HN defined function.

In most programming languages the user-defined and language defined function usages are very similar.

Here is how to do it in HN:-

(1) Create a procedure for instance MyAddFN with any required parameters
     You can create your procedure in a the MainCode section where it will be global.
     Procedures can also be created in cards, buttons etc, where they will be local.

--- Code: ---@ MyAddFN(n1,n2) - simply adds 2 numbers together
Global myResultAddFN

Put n1 into myResultAddFN

Add n2 to myResultAddFN

--- End code ---

(2) In your button place the call to your procedure MyAddFN

--- Code: ---Global myResultAddFN

Call MyAddFN(2,3)

Put myResultAddFN into field 1
@ 5 should appear in field 1

--- End code ---

I try to keep the global variable names similar to the user-defined functions(procedure) because its easier to keep track of them in large programs. However, you can name your global variables anything, as long as they don't conflict with a HN keyword or other variable.

Creating a Procedure

Procedures are created in the Script Editor using the New, Edit, Del buttons in the lower left of the editor window.
Procedures are listed in the listbox directly above these 3 buttons.
Just make sure that you have selected the correct control, card or MainCode before creating your procedure.


This post might help in creating procedures, also know as handlers:-


[0] Message Index

Go to full version