Open Programming Language - Examples

Examples

Here is the console version of a Hello world program:

PROC main: PRINT "Hello World!" PAUSE 40 ENDP

And here is a GUI version for Nokia's Series 80 user interface:

CONST KKeyEnter%=13 PROC hello: dINIT "Hello" dTEXT "","Hello World!" dBUTTONS "OK",KKeyEnter% DIALOG ENDP

OPL is a structured programming language. 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 the language is case independent). 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, 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 there is a button with the text "OK". The second argument to each button is both the special notation of the shortcut key for that button and the dialog's return code, in this case the "Enter" key.
  • Finally, the DIALOG keyword is required for the previously initialized dialog box to be shown on the screen.

Read more about this topic:  Open Programming Language

Famous quotes containing the word examples:

    No rules exist, and examples are simply life-savers answering the appeals of rules making vain attempts to exist.
    André Breton (1896–1966)

    In the examples that I here bring in of what I have [read], heard, done or said, I have refrained from daring to alter even the smallest and most indifferent circumstances. My conscience falsifies not an iota; for my knowledge I cannot answer.
    Michel de Montaigne (1533–1592)

    It is hardly to be believed how spiritual reflections when mixed with a little physics can hold people’s attention and give them a livelier idea of God than do the often ill-applied examples of his wrath.
    —G.C. (Georg Christoph)