Getting Started

Hello World

The next program prints the Hello World message on the screen (std-out).

show "Hello World"

The next program prints the Hello World message with a new line.

showln "Hello World"

Run the program

to run the program, save the code in a file, for example : hello.dgn then from the command line or terminal, run it using Dragon native

dragon hello.dgn

Not Case-Sensitive

Since the Dragon native is not case-sensitive, the same program can be written in different styles

Tip

It’s better to select one style and use it in all of the program source code

SHOWLN "Hello World"
Showln "Hello World"

Multi-Line literals

Using Dragon native we can write multi-line literal, see the next example

Show "
        Hello
        Welcome to the Dragon programming language
        What's going on?

    "

Also you can use the newline variable to insert new line and you can use the + operator to concatenate strings

As we have NEWLINE for new lines, we have Tab and CR (Carriage return) too!

Note

newline value means a new line and the actual codes that represent a newline is different between operating systems

show "Hello" + newline + "Welcome to the Dragon programming language" +
    newline + "What's Going On?"

Getting Input

You can get the input from the user using the readln() function

showln "What is your name? "
cName =  ReadLN()
showln "Hello " + cName

No Explicit End For Statements

You don’t need to use ‘;’ or press ENTER to separate statements. The previous program can be written in one line.

showln "What is your name? " cName =  ReadLN() showln "Hello " + cName

Writing Comments

We can write one line comments and multi-line comments

The comment starts with # or //

Multi-lines comments are written between /* and */

/*
        This is a multi-line 
        comment in Dragon Programming language
*/

showln "What is your name? "       # print message on screen
cName =  ReadLN()                  # get input from the user
showln "Hello " + cName            # say hello!

// showln "Bye!"

Note

Using // to comment a lines of code is just a code style.