Unorganised notes about programming in Exodus

From NEOSYS Dev Wiki
Revision as of 13:59, 24 November 2010 by Steve (talk | contribs) (Reverted edits by Anecada (Talk) to last revision by Steve)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

The following is just a scrap pad of ideas to be incorporated in documentation

new syntax possibility

Some will hate this. Some will love it.

//mass declaration and mass initialisation.
var abc,xyz,qwe;

C++ exodus

  1. Just because you can write C in C++ doesnt mean you should! Dont include C libraries and you wont be able to.
  2. Just because you can write C++ in Exodus programs doesnt mean you should! Dont include C++ libraries and you wont be able to.

if you are only familiar with c then c++ has some improvements for examples like you can declare your variables at the point they are used (and not at the top of the routine like c)

unlike many modern languages c++ retains the infamous goto statement making porting from pick basic much easier. you have to avoid declaring new variables (var xyz) within the scope of the jump but this is easily accomplished by moving the declaration just above the jump zone.

better to put print(a, " ", b) than print(a ^ " " ^ b) because it is faster to do three outputs instead of two concatenations and one output

The following will compile but give throw "unassigned variable" on execution.

var foo=foo.sum();

strings must all be wrapped in " double quotes and single quoted strings are not allowed - except for single character strings. To puta double quote character within a string you must prefix them with \ to be like \".

swap, match and index have an additional argument that can contain r for regular expression and ri for case insensitive regular expression. i by itself doesnt work at the moment.

note the double backslashes in regular expression strings (until we get the R string prefix for "raw strings"

if (word.match("\\d+","ri")) ...

using the results or comparisons as 1 or 0 is not supported so "xxx+(a eq b)" wont compile.

you could put the ugly "xxx+(a eq b?1:0)" but recoding is probably better "if (a eq b) xxx+=1;"

better than pick basic

there are a series of compromises in exodus design which are forced by the limitations of c++ syntax. with time you get used to these.

offset against the disadvantages are many advantages at multiple levels:

local subroutines have a) parameters and b) local variables

gosub/return style local subroutines can have parameters and their variables are private by nature. this allows monolithic programming with many subroutines in one file/compilation unit without all variables being global.

one way of looking at this is that you can now put all your associated external routines in the main program text and are not required to use separate edit/compile to get parameterisation and private variables.

another way of looking at this is that what used to be your external functions and subroutines (but are now are implemented as internal functions) now have access to the global variables of your main program without requiring setup of common variables.

many functions and subroutines per file

pick only allows one function or subroutine per file. c++ is happy with many.

in some cases, editing and compiling groups of associated subroutines and functions in a single file makes it easier to manage your source code base.

faster conditional expressions

the AND and OR operators "short circuit" ie do not evaluate the right hand side if the evaluation of the left hand side predetermines the final result. For example, in the evaluation of "aa() and bb()", if aa() returns false then bb() will never be evaluated.

multiple programming paradigms

object orientated programming - if you want. functional programming - if you want. procedural programming - if you want.

for application level programming you can follow a standard of only allowing the exodus header file to be included. not including any of the traditional c++ headers like <iostream>, <string>, <vector> etc. will prevent programmers getting out of their control. If you want to merge pick with traditional c++ programming you are free to include and header files you like. Just make sure to include the exodus.h AFTER all the other headers.

low level programming and interfacing with other languages

many operating system utilities can be programmed directly in c++ allowing you to do system programming in pick basic syntax

most languages allow interfacing at the C/C++ level so exodus can be used for this directly without depending on any interfaces.


fieldstorer (but not fieldstore) is an “statement-like” or “mutator” function which modifies the existing string instead of creating a new one. It can be implemented internally to be MUCH faster than xx=fieldstore(xx,”*”,2,2,”ii”) which first produces a new string and destroys the old one.

Actually I havent implemented this optimisation internally for all the mutator functions so a performance test might not reveal any difference YET. See a tiny discussion of this issue in on the OO syntax page on wiki.


XX=’aa*bb*cc*dd’ XX=fieldstorer(XX,’*’,2,2,’gg’) PRINT XX



var xx="aa*bb*cc*dd"; fieldstorer(xx,"*",2,2,”gg”); printl(xx);


substr and splice

It is with great sadness that I announce the death of multivalue/pick basic's beautifully concise square bracket syntax [x,y] since it is not available with two parameters in the family of c-like languages.

There is some ugly (and possibly even poor) design in the solutions I have come up with so until the api is frozen .. now is the time for eulogies and pulpit admonishments to the next generation.

[]is replaced by the ugly sisters substr and splice and their mutator cousins substrer and splicer.

substr/substrer is generally the replacement for [] found on the right of the assign like “xx=yy[start,len]” since it extracts a section of characters

splice/splicer is generally the replacement for [] found on the left of the assign like “xx[start,len]=yy” since it replaces a section of characters

The name substr was chosen similar to many other languages c++, javascript, php, perl, basic etc

The name splice was chosen because the obvious name "replace", which is in use in some other languages to replace characters, is already a classic dynamic array function – and splice has a similar function in arrays in many languages.

SUBSTRER is a “statement like” or “mutator” function designed to replace pick xx[start,len]=’’ and perhaps a bit more.

One way of thinking about it is that it cuts off some of the beginning … or some of the ending … or some of both … FAST!

substrer with two parameters example

var xx=”abcde”; substrer(xx,3,2); printl(xx);


substrer with one parameter example

var xx=”abcde”; substrer(xx,3); printl(xx);


OS level command shell

the bash command line shell treats various characters specially including " ' ( ) < > $ ! and others. You must escape/prefix them by \ to stop bash from messing with them.


list file with field = "xxx" (S)


list file with field = \"xxx\" \(S\)

or you can quote everything after the first word of the command. Single quotes allows all special characters to be used. Double quotes allows bash to continue to mess around with special cdoing macro expansion etc.

list 'file with field = "xxx" (S)'

list "file with field = 'xxx' (S)"

exodus allows the use {} can be used for () brackets if at the end of the command

Space no longer means OCONV

in classic multivalue basic two strings separated by space mean use the second as an oconv format to convert the first

print '12345' 'D'


18 OCT 2001

but in exodus, c++ quoted strings are concatenated

print("12345" "D2");



Usually the first bit is a variable

print date1 "D2"

but the equivalent in Exodus will not compile because Exodus doesnt understand the space

var date1=123345;
print(datex "D"); <- compilation error

You need to explicitly call oconv

var date1=123345;

Massive String Text

Spaces between quoted strings in Exodus result in string concatenation at compile time. This is inherited from C++.

var xx="word1" "word2" "word3";

Compile-time string concatenation is useful since long text can be created on multiple lines without requiring any concatenation operator

 var xx=  "line1 line1 line1 line1"
	"\nline2 line2 line2 line2"
	"\nline3 line3 line3 line3"
	"\nline4 line4 line4 line4"
	"\nline5 line5 line5 line5";

You can only use Exodus ^ concatenation operator when either the left or the right bit is an Exodus variable (or the result of an operation on an Exodus variable)

the following will not compile because neither the left or right operand of ^ is an Exodus var

var xx="word2"^"word2";  //compilation error

the following will compile

var yy="word1";
var zz=word1^"word2";
var xx=var("word1")^"word2";