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:
'F'⎕WC'Form'
'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'
'F'⎕WC'Form'('Caption' 'My first form')('Size' 20 20)
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.
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.
Ask Sam about APL / Legacy System Support / APL Consultancy