Creating a Graphical User Interface (GUI) in Dyalog APL (Part 1)

Sam GutsellAPLLeave a Comment

One of the most important things about an application is the Graphical User Interface (GUI for short) as this is how users interact with your app. This is why, over a series of posts, I am going to show you how to build a basic GUI in Dyalog APL.

Create a blank form

In this post I will be using ⎕WC to build a GUI, however, there are alternatives and I will mention these in the last part of this series.

To start with we need a blank form, an empty window where we can later add other GUI objects. To do this we need to run:


this will give you a basic default empty form with the name 'F'.


As I previously said this is a default, empty form, however we can set and adjust properties of the form to make it suit our needs, so let's change the size and caption (the title). The GUI properties can be accessed in the same way we would access the contents of a namespace, using dot notation. We can see what the current size of our form is by running F.Size in the session, as this is a default form this should return 50 50. By default, the size and position properties of GUI objects are defined as a percentage of the size of the parent object, as this is a form object with no other objects defined by us as a parent it uses a percentage of your screen size.

Changing the size of the screen

To change the size of the screen we can treat F.Size as a variable which means we can overwrite the value with a simple assignment. Let’s change it to 20% by 20% by running:

F.Size←20 20


Change the caption property

We can also change the caption property by doing an assignment too, lets change it to ‘My first form’ by running:

F.Caption←'My first form'

Another way of setting these properties is by defining them when we initialise the form by listing the name-value pairs in brackets after the initial form definition. When using this approach be sure to quote the property name and reflect the correct data format of the value. We can define our form with the caption and size properties by running:

'F'⎕WC'Form'('Caption' 'My first form')('Size' 20 20)

One thing to note about defining a form with the same name as one that already exists is that the new one will replace the existing one. This means if you were to define a form called F and run another line that also creates a form called F, the original would be replaced if they are contained in the same namespace.

What next?

In my next post, we will be adding some interactive objects to the form and investigating how we can configure these to suit our needs. If you have any questions about anything I have covered, please leave a comment and I will do my best to answer it.

About the Author

Sam Gutsell

APL Developer

Sam is an APL Developer at Optima Systems. He started at Optima in 2012 as an apprentice straight after finishing College. Sam decided to take Computing whilst studying at college, yet, he never intended to but, he thought it sounded interesting at the time. Sam’s original career plans involved studying Meteorology at university, to become a Meteorologist. His plans changed when he realised how much he enjoyed code. More about Sam.

More from Sam

Other Posts