Open programming language

The Open Programming Language (OPL) is a programming language for the Symbian Operating System that can be found on e.g. the Nokia 9200 Communicator series mobile telephone/PDA. OPL is an interpreted language similar to BASIC.

The language was originally called Organiser Programming Language developed by Psion Ltd, and used on their Psion Series 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.

Contents

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.

  • The dINIT keyword in this example initializes a dialog box (intuitively enough, all dialog-box related functions begin with a letter 'd'; for clarity, this letter is in lower case, but you can mix the case up in your own programs). The first argument of the dialog is an optional string, which is used for the title of the dialog, displayed in the title bar.
  • The dTEXT function displays text (in case that was not obvious), with two compulsory arguments: a left-aligned 'prompt' string, and a main string.
  • The dBUTTONS keyword allows you to put buttons on the dialog box - here we have a button with the text "OK". The second argument to each button text is both the special notation of the shortcut key for that button and the dialog's return code.
  • Finally, don't forget the DIALOG keyword, which is required for the previously initialized dialog box to be shown on the screen.

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 Series 5mx this was changed to a so-called 'OPX' library, stored in the system ROM (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.

External links

Navigation

  • Art and Cultures
    • Art (https://academickids.com/encyclopedia/index.php/Art)
    • Architecture (https://academickids.com/encyclopedia/index.php/Architecture)
    • Cultures (https://www.academickids.com/encyclopedia/index.php/Cultures)
    • Music (https://www.academickids.com/encyclopedia/index.php/Music)
    • Musical Instruments (http://academickids.com/encyclopedia/index.php/List_of_musical_instruments)
  • Biographies (http://www.academickids.com/encyclopedia/index.php/Biographies)
  • Clipart (http://www.academickids.com/encyclopedia/index.php/Clipart)
  • Geography (http://www.academickids.com/encyclopedia/index.php/Geography)
    • Countries of the World (http://www.academickids.com/encyclopedia/index.php/Countries)
    • Maps (http://www.academickids.com/encyclopedia/index.php/Maps)
    • Flags (http://www.academickids.com/encyclopedia/index.php/Flags)
    • Continents (http://www.academickids.com/encyclopedia/index.php/Continents)
  • History (http://www.academickids.com/encyclopedia/index.php/History)
    • Ancient Civilizations (http://www.academickids.com/encyclopedia/index.php/Ancient_Civilizations)
    • Industrial Revolution (http://www.academickids.com/encyclopedia/index.php/Industrial_Revolution)
    • Middle Ages (http://www.academickids.com/encyclopedia/index.php/Middle_Ages)
    • Prehistory (http://www.academickids.com/encyclopedia/index.php/Prehistory)
    • Renaissance (http://www.academickids.com/encyclopedia/index.php/Renaissance)
    • Timelines (http://www.academickids.com/encyclopedia/index.php/Timelines)
    • United States (http://www.academickids.com/encyclopedia/index.php/United_States)
    • Wars (http://www.academickids.com/encyclopedia/index.php/Wars)
    • World History (http://www.academickids.com/encyclopedia/index.php/History_of_the_world)
  • Human Body (http://www.academickids.com/encyclopedia/index.php/Human_Body)
  • Mathematics (http://www.academickids.com/encyclopedia/index.php/Mathematics)
  • Reference (http://www.academickids.com/encyclopedia/index.php/Reference)
  • Science (http://www.academickids.com/encyclopedia/index.php/Science)
    • Animals (http://www.academickids.com/encyclopedia/index.php/Animals)
    • Aviation (http://www.academickids.com/encyclopedia/index.php/Aviation)
    • Dinosaurs (http://www.academickids.com/encyclopedia/index.php/Dinosaurs)
    • Earth (http://www.academickids.com/encyclopedia/index.php/Earth)
    • Inventions (http://www.academickids.com/encyclopedia/index.php/Inventions)
    • Physical Science (http://www.academickids.com/encyclopedia/index.php/Physical_Science)
    • Plants (http://www.academickids.com/encyclopedia/index.php/Plants)
    • Scientists (http://www.academickids.com/encyclopedia/index.php/Scientists)
  • Social Studies (http://www.academickids.com/encyclopedia/index.php/Social_Studies)
    • Anthropology (http://www.academickids.com/encyclopedia/index.php/Anthropology)
    • Economics (http://www.academickids.com/encyclopedia/index.php/Economics)
    • Government (http://www.academickids.com/encyclopedia/index.php/Government)
    • Religion (http://www.academickids.com/encyclopedia/index.php/Religion)
    • Holidays (http://www.academickids.com/encyclopedia/index.php/Holidays)
  • Space and Astronomy
    • Solar System (http://www.academickids.com/encyclopedia/index.php/Solar_System)
    • Planets (http://www.academickids.com/encyclopedia/index.php/Planets)
  • Sports (http://www.academickids.com/encyclopedia/index.php/Sports)
  • Timelines (http://www.academickids.com/encyclopedia/index.php/Timelines)
  • Weather (http://www.academickids.com/encyclopedia/index.php/Weather)
  • US States (http://www.academickids.com/encyclopedia/index.php/US_States)

Information

  • Home Page (http://academickids.com/encyclopedia/index.php)
  • Contact Us (http://www.academickids.com/encyclopedia/index.php/Contactus)

  • Clip Art (http://classroomclipart.com)
Toolbox
Personal tools