Tutorial 01: A Simple Program

Dec 15, 2008

© NSB Corporation. All rights reserved.

Purpose

The purpose of this tutorial is to demonstrate how a simple program is created using NS Basic/Symbian OS. You should have NS Basic/Symbian OS installed before beginning this tutorial.

Description of the Program

The program to be developed will display a form with a button on it. When the user taps the button, the program responds with the message

 "Hello--Welcome to NS Basic/Symbian OS"

Program Development

1. Startup

2. Modify Project Properties

3. Modify Form Properties

4. Add a button to the form

Change the button's text:

Resize the button:

Relocate the button on the screen:

5. Add commands to be executed when the button is tapped

 

6. Save the Project

7. Generate the Downloadable App

If you have any errors, an error message will appear and the code window will appear with the section of code where the error occurred highlighted. Errors must be corrected and Compile repeated until there are no more errors. If you do not have errors, a message box will appear showing the size of the compiled application.

Congratulations !! You have now written your first NS Basic/Symbian OS program.

Testing The Project

First, make sure your device is connected to your computer using the Nokia PC Suite or equivilent.

 

Extending the Tutorial

Let's explore some further features of NS Basic/Symbian OS. We'll do this by modifying your first program to be more complicated.

Exit NS Basic/Symbian OS by choosing File and Exit from the menu.

Restart

Revision: Change the message

	Dim s as string
	Dim d as date
	d=today()
	s=str(d)
	MsgBox "Today is " + s 

 

Revision: Add code at program startup

	msgbox "HelloPgm will continue when you tap on OK"

This code will be executed when the program starts execution. The program displays the message and waits until the user taps on the OK button

Revision: Code at Form display time

This change will add a field which shows the time-of-day. Another button will be added to cause the time to be updated with the latest time.

Add a field to the form to be used to display the time of day

Add code to fill in the time-of-day when the form displays

	dim wk as string
	dim t as time
	t = now()
	wk = str(t)
	fldTime.text = wk

 

This code will set the time of day into the field object "fldTime" just after the device displays the form to the user. The statement

	t = now() 

gets the current time and stores it in the time variable "t". The str function converts the internal time format into a text string of the format hh:mm:ss which is the used to store into the field object for display.

The above code could be compressed into one statement as

	fldTime.text=str(now()) 

Add a button to redraw the form so that the latest time appears

Add code to the button to cause the redraw

	Redraw