Writing a Program

 

| HOME |

A program consists of a collection of interactive command that you usually type them at the prompt.  However, some commands can be only used in the program, for example if, for, while, etc., while other are acceptable both in program and at the prompt, e.g. set, list etc.  Please consult the Command section for individual details of each command.

The following is a guide line for writing a Noobeed program.

  • A line starts with a slash symbol, “/”, is considered a non-executable statement.
  • A line with all white spaces is a non-executable statement.
  • A program must be store as an ASCII file, under a certain directory, defined by the "set pathprg" command.
  • A program must be loaded into Noobeed memory, using command "load", before it is run.
  • To run a program, that is already loaded, just type "run" at the prompt.
  • Insert command "stop" to temporary stop the program.  To continue, type "resume" at the prompt.  They are to help debug the program.  Also inserting command "print" from time to time is another good technique.
  • Almost all built-in functions in Noobeed work very real fast, as they are written in C++ language.  On the other hand, by its nature, interpreter work can be very slow.  Put a very big effort to minimize interpreter work as much as you can.  Even you have to walk around a lot more steps than usual just to arrive at a particular built-in function, the effort is still worthwhile.  A single loop is normally fine.  Put a second loop inside the first loop might increase the computed time dramatically, as the number of operation increases from n to n2.  So, rather than access to each single element in a matrix using two commands "for" loop, try using a built-in function that operated on a matrix as a whole.  Loop commands do nothing, but repeat the work of the interpreter over and over.  So please use them carefully.

How to create and run a program

Any text editor can be used to write a Noobeed program, for example "Notepad", "Wordpad". 

Please also note that all the Noobeed commands are not case sensitive.  However commands in this demonstration are often shown in capital characters.

Once a program is created, it must be saved in the hard disk of the computer.  Suppose that a program is stored in the directory “c:\prg” as a name of “test1.prg”.  To run “test1.prg”, simply type

-> LOAD “test1.prg”

You can omit the file name extention “prg” as it is the default extention of program file.

If for some reasons, Noobeed does not find the program, it will say

->File < test1.prg> not found.

We are going to set the program path by typing

->SET PATHPRG “c:\prg”

 By typing the command set pathprg alone, with no parameter, it will print out the current program path.

 Once the program is loaded successfully, type

 ->RUN

 

My first Noobeed program

The program “hello world” would be too easy to demonstrate here.  Rather we are going to write a simple program to solve the following problem.

“Given numbers from 10 to 90, we want to calculate a summation of either sine or cosine function of these numbers, according to the following condition.  If the number is odd, we want its sine function and if the number is even, we want the cosine function”.

Here is the program

/ set the ANGLE mode to degree
  set angle “deg”

/ n1 and n2 is the start and end value
  n1 = 10
  n2 = 90

/ sum is to store the result
  sum = 0

/ use FOR loop and call global functions "sin" and "cos"
  for i = n1, n2
    if is_odd(i)
      sum = sum + sin(i)
    else
      sum = sum + cos(i)
    end
  end

  print "result = " sum

 


| HOME