Open programming language |
The Open Programming Language (OPL) is a programming language for the Symbian OS that can be found on e.g. the Nokia 9200 Communicator series mobile telephone/personal digital assistant. OPL is an interpreted language similar to BASIC programming language.
The language was originally called Organiser Programming Language developed by Psion for the legendary Psion Organiser, and used on their Psion 3 and later PDAs. After the project was changed to open source, the acronym was re-interpreted. The language is now developed on SourceForge in the opl-dev project.
=Examples=
Here is a small Hello world program:
PROC main: PRINT Hello World PAUSE 40 ENDP
(Source code taken from the PCDevPrimer in the OPL Wiki.)
And here is a GUI version:
PROC hello: dINIT Window Title dTEXT , Hello World dBUTTONS OK ,13 DIALOG ENDP
OPL programs contain PROCedures, which are much like functions in other programming languages.
==Testing Dialog Responses==
An example:
PROC test: dINIT Your Challenge dTEXT , Will your answer to this question be no dBUTTONS Yes ,%y, No ,%n IF DIALOG=%y PRINT No it wasn t! ELSE PRINT Yes it was! ENDIF GET ENDP
In this cruel interrogative program, the Yes button is assigned the shortcut of Ctrl+y, while No has Ctrl+n, represented by %y and %n respectively. The user s input from the DIALOG is tested in the IF statement, PRINTing appropriate responses to the screen. Note that the GET keyword, which gets user input without using a dialog box, is here used simply to wait for a keypress before terminating the program (otherwise it would end immediately without giving time for the user to groan at the ridiculousness of the question asked them). The output from DIALOG can also be stored in a variable.
Variables specific to a procedure must be declared with the LOCAL keyword; global variables are defined with the GLOBAL keyword.
==Variable Types==
The table below uses an example variable called var .
Data TypeSyntax Floating Pointvar Integervar% Long Integervar& Stringvar$( length )
=Minutiae=
OPL interfaced with advanced Psion Series 3 features by means of operating system CALLs, but in the later Psion 5 this was changed to a so-called OPX library, stored in the system Read-only memory (the Z drive).
Other OPL features include those with a letter g at the beginning, for graphical functions; and those with a letter m , for menus. If only all programming languages were this simple.
=See also=
Organiser Programming Language
=External links=
|
|