"Hello world" - How to Execute PPL Code

Christian Neumanns

2016-10-01


Table of Contents
Introduction
PPL Script File
OS Command Line
PC Application

Introduction

This tutorial shows different ways to write the famous Hello world program in PPL.

[Note]Note
To try out the examples you must first install PPL.

PPL Script File

A script in PPL is a list of source code instructions. A single script can be stored in a text file and then be executed by an OS command.

Example:

  • Use your preferred text editor and create a file named hello.ppl in any directory and with the following content:

    OS.out.write_line ( "Hello world" )
  • Execute the script by typing the following command in a system terminal:

    ppl hello.ppl
    [Note]Note
    If your current directory is different from the directory of the script file then you must specify a relative or absolute path to the script file, for example:
    ppl ../tests/hello.ppl
  • The result is displayed in your terminal:

    Hello world

More information about working with scripts can be found here.

OS Command Line

You can use an operating system command to execute a single PPL instruction or evaluate a single PPL expression:

  • Execute a PPL instruction:

    Invoke PPL with the execute_instruction command (or its shortcut ei).

    Example: Type the following in a system terminal:

    ppl ei "OS.out.write_line ( \"Hello world\" )"
    [Note]Note
    The backslash (\) is used as escape character in OS command line arguments.

    Result:

    Hello world
  • Evaluate a PPL expression:

    Invoke PPL with the evaluate command (or its shortcut ev).

    Example to evaluate the expression "Hello" & " world":

    ppl evaluate "\"Hello\" & \" world\""

    Result displayed:

    Hello world

    Another example:

    ppl ev "4 * 7"

    Result:

    28

PC Application

To create a "Hello world" application do the following:

  • Open a terminal window and go to any directory in which you want to create the project.

  • Create a new project named hello by entering the following command:

    ppl create_project id=hello

    PPL creates a sub-directory structure named hello.

    You can have a look at the README file in the project's root directory.

  • File hello/work/ppl/source_code/hello/ contains the entry code that will be executed when the application starts.

    Open this file with your preferred text editor, look at the comments, and insert the following instruction in the script of command start:

    OS.out.write_line ( "Hello world" )

    The whole source code should look as follows (comments removed):

    service hello_starter
    
       command start
          in command_line_arguments nullable indexed_list<nullable string>
    
          script
             OS.out.write_line ( "Hello world" )
          .
       .
    
    .
  • Save the file.

  • Compile and build your project by executing the compile_and_build system file which is located in your project's root directory (i.e. compile_and_build.sh on Unix and compile_and_build.bat on Windows).

  • Now run your application by executing the run system file in your project's root directory (i.e. run.sh on Linux systems and run.bat on Windows systems).

    Your screen displays:

    Hello world

More information about creating PPL applications can be found here.