Manual

From NEOSYS Dev Wiki
Revision as of 13:24, 25 October 2010 by Steve (talk | contribs) (Created page with '=== Hello World === After installing Exodus, you can develop Exodus programs from any operating system command line. ==== Edit ==== Use Exodus's all-in-one editor+compiler+cat…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Hello World

After installing Exodus, you can develop Exodus programs from any operating system command line.

Edit

Use Exodus's all-in-one editor+compiler+cataloger 'edic'

edic hello1

edic will give you a skeleton Exodus program which you can develop as you wish.

There must be one and only one "function main()" statement and this is run when the program is started.

By convention, main() must return an integer value. If desired, this can be used to indicate "success" with zero or "failure" with some error number.

The programinit() and programexit() lines are required and provide all the standard multivalue system variables using a simple C++ class macro.

#include <exodus/program.h>

programinit()

function main() {
        printl("hello1 says 'Hello World!'");
        return 0;
}

programexit()

Save and compile

Make any changes you want in to the skeleton and save it.

NB If you just want to try out the skeleton program as is then you must still explicitly save it otherwise if you just exit without saving, edic will assume you have changed your mind and do not want the hello1 program after all and will cancel. For the default editor 'nano' explicit save is usually Ctrl+O.

On saving hello1, edic will compile and catalog it.

Run

To run/open/execute your new hello1 program just type its name.

hello1

and the output is ...

hello1 says 'Hello World!'

Local subroutines

To simulate classic multivalue basic's "gosub/return" in Exodus, you add additional subroutine and functions above or below your "main" function.

In Exodus's you dont need to local subroutines are functionally almost identical to external subroutines and functions so you can move your external subroutines and functions into the main program source code if you wish.

Local subroutines and functions (including the "main" function) can be any order. There is no rule that functions must appear before or above the code that calls them.

Exodus's local subroutines and functions are rather different and arguably much better than classic multivalue local subroutines since they have their own set of variables.

  1. can be called with parameters e.g. gosub funcx(xx,yy,zz)
  2. except for program global variables all variables are private (preventing many bugs)
  3. can return a result e.g. abc=funcx(xx,yy,zz)

Essentially they are identical to *external* functions and subroutines except that 1) they are written in the main program and 2) they have access to the programs global variables.

They do not have any access to the variables of the calling program unless they are passed as parameters or are defined as global variables.

They only have one entry point whereas in classic multivalue basic you can jump into the middle of any local subroutine. To simulate this type of coding in in Exodus you must create nested subroutines or functions.

The old RETURN TO XYZ syntax is not supported at all and such code must be redesigned to eliminate it.

External functions and subroutines

Editing and compiling external subroutines and functions in Exodus is identical to normal programs except:

  1. "program" become "library" so we have "library.h", "libraryinit()" and "libraryexit()".
  2. function main can have any parameters you like eg "function main(in arg1, in arg2, out arg3)
edic func1
#include <exodus/library.h>

libraryinit()

function main(in arg1, in arg2, out arg3) {
        printl("func1 says 'Hello World!'");
        return 0;
}

libraryexit()
edic prog1
#include <exodus/program.h>

programinit()

#include "func1.h"

function main() {
        printl("prog1 says 'Hello World!'");
        return 0;
}

programexit()