Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Open Programming Language
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Examples== Here is the console version of a [["Hello, World!" program]]: PROC main: PRINT "Hello World!" PAUSE 40 ENDP <small>''(Source code taken from the PCDevPrimer in the OPL Wiki.)''</small> 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 ([[subroutine]]s) 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. ===Testing dialog responses=== An example: <syntaxhighlight lang="basic"> 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 </syntaxhighlight> 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 read the text). 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 named <code>var</code>. {| class="wikitable" |----- ! [[Data type]] ! [[Syntax (programming languages)|Syntax]] |----- | Floating point || var |----- | Integer || var% |----- | Long integer || var& |----- | String || var$(''length'') |}
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)