Home > Epoc > Samples > Combination > OPL
 
  Combination in OPL
(Organizer Programming Language)

 Purpose

This is the OPL version of our combination application.

 Requirements

You need Epoc OPL SDK (see tools section).

 Source code

Below is the opl file.

For .opo, please download the ZIP file.

REM Combination
REM Epoc
REM OPL

INCLUDE "CONST.OPH"

PROC go:
    LOCAL n%,p%

    FONT KFontCourierNormal18&, KgStyleBold%
    
    STYLE 4
    PRINT "Combination > Epoc > OPL"
    PRINT

    STYLE 2
    PRINT "Enter value for 'n'";
    STYLE 0
    PRINT ": ";
    INPUT n%

    STYLE 2
    PRINT "Enter value for 'p'";
    STYLE 0
    PRINT ": ";
    INPUT p%

    PRINT
    
    STYLE 0
    PRINT "Factorial(";n%;") = ";factorial:(n%)
    PRINT "Factorial(";p%;") = ";factorial:(p%)
    PRINT "Factorial(";n%-p%;") = ";factorial:(n%-p%)
    PRINT "Combination(";n%;",";p%;") = ";combination:(n%,p%)
    
    PRINT
    PRINT "[Press 'Enter']"
    GET
ENDP

PROC factorial:(n%)
    IF (n% <= 1)
        RETURN 1
        ELSE RETURN n% * FACTORIAL:(n% - 1)
    ENDIF
ENDP

PROC combination:(n%, p%)
    RETURN factorial:(n%) / (factorial:(n% - p%) * factorial:(p%))
ENDP

 Comments

OPL is a BASIC-like language. There's hardly any overhead, here!

Another great asset of OPL is that you can develop your apps on your device as well... No need to carry your desktop computer in your bag!

Just like PocketC (for Palm and Pocket PC), OPL is a very convenient language for on-device development.

Install Combination (source code) and Combination.opo (executable) in any folder on your device or on the emulator, locate the .opo and run it! As EZ as 123 :)

There's also an ASCII version of the source code in Combination.txt, that you may want to load in your OPL Editor with the import feature. This is equivalent to the installation procedure above.

The core functions are: factorial:(), combination:() and go:().

Here's another screenshot of WINS emulator with the skin of a Sony-Ericsson P800:

To do this, you need to set up a P800.ini file in the \Epoc32\Data folder that contains the skin description. For your convenience, the P800.bmp is in the .zip mentioned above. Here's how the .ini looks:

ScreenWidth 205
ScreenHeight 324
ScreenOffsetX 57
ScreenOffsetY 159
LedOffsetX 120
LedOffsetY 32
LedArrangeHorizontally
LedGap 10
LedSize 0
_EPOC_DRIVE_T F:\Tmp\Epoc

Next sample

 
[ Copyright © 2000- Eric Poncet - All rights reserved ]

[ Stage de musique classique | Stage de musique baroque | Stage de musique de chambre | Stage de musique latine ]
[ Stage de jazz | Stage de musiques actuelles | Stage de funk | Stage de metal | Stage de pop | Stage de reggae | Stage de rock ]
[ Stage d'improvisation | Colonie musicale ]