Quick Start Tutorial

Previous Next

Quick Start Tutorial.

This step-by-step tutorial guides you through a complete - yet very simple - programming example. It is just a small example of what SCRAMBLECODE offers, but it is well suited to demonstrate a few important things about the language and the Integrated Development Environment (IDE).


Please be aware:


What is Presented.

You will be introduced to these individual steps:


Tutorial Steps

Description

Create New Project

We start by defining the project properties which are saved to the project file.

Add Source File

Then we add a file to contain the source code.

Insert Main

The Main class with the Main function is inserted into our source file. This is the entry point where the execution will start.

Modify Source Code

We add some simple source code (exemplified below) for a simple demonstration of the editor.

Compile to ByteCode

The compiler creates the bytecode in memory - ready to be executed by the evaluation VM DLL.

Run ByteCode in VM

The bytecode is executed in the test bench, which is an integrated part of the IDE.

Debug Execution

Debugging is presented allowing you to follow the bytecode execution in great detail.


The tutorial uses this source code:



Class Main

{

 Public Function Main(Integer x, y, z) : Integer

 {

   //Create our text variable.

   String text := "X=" + x.ToString() + " and Y=" + y.ToString();


   //Convert text to UTF8 bytes, rotated z bits left.

   Blob crypto := Encrypt(text, z);


   //Write to the public VM cells, which are readable to the host.

   //Each cell is assigned as @CellSetType(rowIdx, columnIdx, value).

   @CellSetString(1, 1, text);

   @CellSetBytes(1, 2, crypto);


   Return crypto.Length();

 }


 Private Function Encrypt(String text; Integer rotateBitsLeft) : Blob

 {

   //This is a very simple encryption which turns the text

   //into UTF8 bytes, and then rotates the bits to the left

   //(or alternatively to the right if rotateBitsLeft < 0).


   Integer cpUTF8 := 65001; //the utf8 codepage;

   Blob tmp := @EncodeStringToBytes(text, cpUTF8);

   Return tmp.Rotate(0, rotateBitsLeft);

 }

}



This example:


Your Involvement.

Each time you are required to do something, it is described like this:

» This red symbol indicates your actions. Please follow the instructions in the specified order.


Some of these actions involve using menu functions located in the IDE Menu Structure. One action could for instance be the File > Save operation. When using this notation it means you should first open the File Menu, which can be opened as a fly-out menu by hovering your mouse over the main menu or by typing the shortcut Alt+F, and then click the menu item Save.


Next: Create New Project