The MyPitSelf language evolves constantly because of its own concept and because improvements are brought, but it will remain with only function calls returning true or false.

It is a "blending" of
lisp for the nested treatments and true or false return values
C for the function calls
Assembler for the stack mechanism

The best method to learn this language is like for all languages:
- Look and do the development examples given above, this will make you familiar to the basic concepts and the development environment.
- See examples of this language. for this, go to the MyPitSelf environment as user 1/1 and to choose in the tool menu the button "Set or unset Developping mode for MyPitSelf" and to look at the
functions.

This function refererence is mostly done so that when I need to write some source, I can copy the example and then paste it in the source.

When you are in the function list, the button gives a result under a table view.
In other words, if a function is f(g(x),h(y)), the table result of this function is

Function#

Parent
Number

Order In
Parent

Function
Name

Function
Type

Number Of
Children

Level

0

-1

0

0

INIT

1

0

1

0

1

f

formula

2

1

2

1

1

g

formula

1

2

3

2

1

x

zone

0

3

4

1

2

h

formula

1

2

5

4

1

y

zone

0

3

With these data, a procedure can implode it to rebuilt the original string [ f(g(x),h(y)) ].
This means that if some modification are done on the language structure, by putting this table in a database table and working on it ( ie add/move/suppress records ), one can make the functions
evolve.
For example, like in the functions attached to a list, I decided once to put the field specification inside a Field() function.
The old format was:

Tac(
T0.ID,
doSomething(),
)

And the new format is:

Tac(
Field(T0.ID),
doSomething(),
)

To do this, I wrote functions that did that job.
That is the reason why even if I know that certains things have to be corrected, I do not panic about correcting all the sources.

Furthermore, the possibility to put the function in tables helps to trace every use of data. As the SQL phrases are written in database in an organized way and then translated into languages
functions, one can know which data is used where.

The use of this possibility is for the moment in only few places but will be generalized to have a trace of everything.

Some functions have no arguments, some others fixed arguments, some others fixed functions arguments and other variable functions arguments.
A function always return true or false.

The arguments of the functions are inclosed in parenthesis and separated by comas.

Line comments start with // and they end with the end of line.
Block comments start with /*, end with */, these delimiters must be on the first column and can be nested.
The ' is a string delimitter, the escape character is \

Variables can contain any basic type of data ( strings, dates, times...) but not yet arrays
There are two sets of variables.
Some are declared and named ( see SetVar below ) and are contained in a stack: It's the variable stack.

Others are put in a stack by programs. It's the Call Stack.
As MyPitSelf is based on data, some instructions extract data from the databases and puts them in the call stack.

The way to reach the variables put in the call stack is by giving a number which represents the position in the call stack:
If the call stack contains ( it is filled going downwards )

SetVar(xxxx,yyyy[,yyyy]) for local variables
or
SetVarG(xxxx,yyyy[,yyyy]) for global variables

Where xxxx can be:
a variable name ( no spaces or special characters admitted )
Var(xxxx) : The content of the variable whose name is xxxx. ( equivalent to the $$ in php ).

yyyy can be:
-Var(zzzz) or VarG(zzzz): The content of the variable zzzz, zzzz must exist.
-Chr(n): where n is the ascii code of a character. It is useful for specials characters like Chr(10) or Chr(13)
-Cst(xxxx) : A constant, it can be a string or a number.
-n: A number which represents the niest last character of the CallStack.
-Display(nnnn) : nnnn is the message number in the msg list ( usefull for internationalisation )
-Funct(nnnn) : nnnn is a function number: It replaces the Cst(nnnn) because if someone give a new number mmmm to nnnn, all Funct(nnnn) will be moved to Funct(mmmm).
-Stack(oooo) : oooo is a name of a variable which contain the position of the element to fetch in stack.
-SessionVar(ssss) : ssss is a name of a constant to get in $_SESSION .
-HttpPostVar(pppp) : pppp is a name of a constant to get in $_POST .
-Num(qqqq,x) : qqqq is a name of a variable, x is the number of decimals.
-Env(rrrr) : rrrr is a constant representing the environment variable to get ( php getenv() )
-XVS(zzzz) : gets the content of the variable which is in the Variable stack ( zzz is the variable name )

An environment has it's own variables like
the folder of it's programs
The user code of the current user,
Default values for data ....

Go to the profile menu and use the "see/hide function call" button to see function calls.
Then a button appears on the main menu ( print variable stack ).
These predefined variables can be seen using this button. They start with xxx.
These variable are in the variable stack just like the ones the ones declared with SetVarG.
The pvs() function can be used to display variables in a program.

For the moment, one can update these variable which is absolutely not correct and has not to be done but this will be enhanced to have more control on the use of the "system variables" according to the user profile.

Tac(
Var(xxxx), // xxxx is a variable name
VarG(xxxx), // xxxx is a variable name
Cst(yyyy) // yyyy is a constant.
Chr(zzzz) // zzzz is a numeric value for an ascii code
Display(nnnn) // nnnn is a message number.
Field(Tn.FieldName) // The FieldName can be use in LISTFUNCT functions, ie T0.Name
Funct(oooo) // oooo is the number of the function to call
ffff(), // ffff is a function to call whose name is not
// one of the previous in this list
// The Function is called for execution
)

Example:

Tac(
SetVar(MyVar,Cst(Hello,world)), // defines a variable "myVar" and puts hello, world in it
Var(MyVar), // push the variable in the call stack
out(1) // outputs the last variable in the call stack
) // all variables pushed in this Tac() are poped

The Tn.Field name must be at the level one of the function. In this case the variable is transformed into a constant. ( use the Show source of your browser to see how the FUNCTION field is filled
in any list screen ).
So if a LISTFUNCT function is

Tac(
Field(T0.ID),
out(1)
)

and the result button is in front of the record ID 1234, the source will show something like:

Puts in the call stack the value of a variable.
It is usually used to return some values: as this language returns only true or false, if you want to get something different from a function call, you can use the call stack and put some values in
it.
Example

// Receives the field code and builds the string to build the sql for this field
SetVar(FieldCode,1),
Tac(
Var(FieldCode),
R_1523_Select(
Do(
Take(T0.Name,T0.xRefData),
SetVar(FieldName,2),
SetVar(DataCode,1),
Tac(
Cst(0), // not system
Var(DataCode)
Funct(6091), // builds for example ' varchar(50) NOT NULL
SetVar(SqlString,Cst('`')Var(FieldName),Cst('`'),Ret(1))
// now, SqlString contains `TheFieldName` varchar(50) NOT NULL
)
)
)
Swap(SqlString,1), // the function calling this one can do a
// SetVar(SqlField,Ret(1))
)

where xxx is the condition: It can be a function ( and usually is ).
yyy is the series of function to do if the condition returns true
zzzz is the series of function to do if the condition returns false
If one or both of ReturnIfxxxx() are not mentioned, the returned value is true if the condition matches the ReturnIf ommitted.
Example 1:

SetVar(ValueToTest,1),
Tac(
Var(ValueToTest),
Test(
Cond(Equal(0)), // the function Equal return true if the last value in varstack = it's argument.
IfFalse(
Msg(This will never be displayed but the program continues)
)
)
)

The Equal function can take as argument:
a constant: can be a string or a number
Var(xxx): a variable whose name is xxx
f(): a function. Example 2:

SetVar(ValueToTest,Cst(1)),
Tac(
Var(ValueToTest),
Test(
Cond(Equal(1)),
IfTrue(
Msg(I do not want to continue so I exit the program ),
ReturnFalse() // this instruction stops the program returning false
)
)
)

Compares the last value in the call stack to some constants to execute functions

SwitchCase(
x01,f01(),
x02,f02(),
.,
.,
.,
[flast()]
)

x0i are constants, f0i are functions
If none of the constants are matched and there is NOT a last function, without a constant before, it returns false
If none of the constants are matched and there IS a last function, without a constant before, it executes this last function
Examples:

Copy file matching a given pattern from a directory to an other one.
Example: The .css files are created in the MyPitSelf environment. After their creation, they must be copied in the other programs so this function is used:

where xxxx is the number of the sql request. It must be a SELECT LIST type.

zzzz is a variable which contains a string to display

a0_list is also used when there is a value to fetch in an other table ( see the XREF functions ). In that case iiii is the name of the field to fetch ( generally, T0.ID )
jjjj is the name of the field to see ( generally T0.Name )

kkkk is the number of a MyPitSelf function called to output the line header of the table
llll is the number of a MyPitSelf function called to output each line
nnnn is the number of a MyPitSelf function before displaying the list
oooo is the number of a MyPitSelf function after displaying the list
nnnn is the first line to display

Important point begin:
A request for a list has generally some input criterias. The todo request for example is

The values %SQLPARn% are the input criterias for the todo list. These values must be put in the call stack before the call to a0_list and you must add the number of parameters of the request as
the last value in the call stack.

where
xxxx = Create or View or Update or Duplicate: Action to do with the record
yyyy = the sql number to use
zzzz = name of the variable containing a string to display
iiii = Function number to call after an Update, a Duplicate or a Create.
The difference between After() and ScreenAfter is the type of the function iiii.
The ScreenAfter function usually ask some data .
Example:
When the super user creates a new user, the next screen that comes after the "CREATE" button is the one that ask the user password which is function # 4021, so it gives:

a0_Screen(
Mode(Create),
Sql(1014),
ScreenAfter(Funct(4021))
)

jjjj,kkkk if some fields are hidden in the Sql request, this lets you fill the field with a value.
NoLock(): Usually, an update must lock the record so that someone else can't modify it. But in certain cases, the lock is not wanted.
NoLog(): Usually, a View option is logged in the system so that when you click on the Back button, you can see the screen again. But, in certain cases, the loggin must not be done so you can use
this verb.
Under(Funct(llll)): where llll is a function number: If the Mode() type is update or View, llll represents a function that is called after displaying the screen. This last function receives as a
parameter the ID of the record being displayed.

The values of the parameters must be pushed in the call stack before this call.

Note that the T0.Code, the auto incremented field is hidden ( go to the Request menu for select 1002, click on the Fields button, and View the T0.Code Field ).
So the creation of a todo record looks like:

a0_Screen(
Mode(Create),
Sql(1002)
)

The update of a todo record looks like:

Tac(
Field(T0.Code), // first and only parameter of the request
a0_Screen(
Mode(Update),
Sql(1002),
NoLock()
)
)

Note: If a function is attached to the main table of the request then this function is called before the Update/create/Duplicate of the record.

The fields in these functions are available as VarG ( global variables ) and are referenced as TnFieldName WITHOUT a . between Tn and FiendName.
This comes because it's the value from the screen which is tested and not the value from the table.

a0_AskData(
[Display(xxxx),]
LaunchButton(Display(ZZZZZZ)),
Par(yyyy,zzzz,Default(Var(kkkk)),OnUpdate(Funct(1234)),[,,,]
[LaunchButton(llll),|NoLaunchButton()]
Tac(
SetVar(Value0,Input(0)),[,,,]
ffff()
)
)
where
xxxx: can be a number and it displays the message number xxxx or Var(VariableName) ant it displays the content of the variable VariableName

llll = Display(iiiii) or Var(eeeee) to display a different text on the launch button than "GO"

yyyy: a string and if equals to Display(nnnn) it displays the message number nnnn

zzzz: either Data(iiii) where iiii is a number of a data in the Data menu
or a function to get the value from a table like

Usually, the calls to the functions happen only in list functions. But sometimes the menus call functions that are not lists.
If you wish to use the backs button in this case, use this function.
Example: to display the documentation chapters in MyPitSelf, the function 6770 starts with

As we use HTML, PHP, JavaScript containing HTML or Javascript containing Alert() function, many cases are
possible because the string delimiter, the carriage return, the ditable fields can contain many cases.
Keep in mind that the string delimiter in MyPitSelf is '.
The ' can be put in a string using \'.
The \ can be put in a string using \\.

Converts a string to a string that can be the content of a javaScript alert message.
The line feed (lf) is converted to the \n
The carriage return ( cr ) is converted to nothing
the \ is converted to \\
the ' is converted to \'

Converts a string to a string that can be the content of a javaScript variable.
The line feed (lf) is converted to the BR tag
The carriage return (cr) is converted to nothing
the \ is converted to \\
the ' is converted to \'

This function initialises a tree:
The tipical use of this function is:

Tac(
SetVar(out,Cst('<table><tr><td class="zz_record">')),
Ech(Var(out)), // the tree is embeded into a table
JsTreeInit(d1,treeCurr,treeInit,Funct(0001),Funct(0002)),
// d1 is the javascript tree object
// funct 0001 is the function to activate a branch
// treeCurr is the reference to the current displayed Id
// treeInit is the reference to the root id of the tree
// funct 0002 is the function to manage the fold/unfold + and - buttons
//========= <branches
Cst(d1), // name of the JsTree object
Var(treeInit),
Var(treeInit),
Var(treeCurr),
Var(treeList),
Cst(0),
Funct(0003) // function to display a branch
//========= branches>
JsTreeOutput(d1,treeList), // outputs the tree
SetVar(out,Cst('</td></tr></table>')),
Ech(Var(out)),
)

An other function is used for the root of a function that manages the possibility to move the branches of a tree.

Every sql request with a type = SELECT or INSERT or UPDATE or DELETE or DELETE VALUE you create will produce a function.
This function can be used in the language to do the work

The FIRST EXAMPLE section of this documentation give some examples of the use of this button.
When you use this button, all the informations about the request are put in tables so the request can be regenerated and can be analysed according to it's type and thus, it's use.

The request generated with this button are simple. No LEFT/RIGHT JOIN are possible yet.
You can add some little enhancements by using the "Complementary field" or the "And more" fields.

If you need a very complex request, you can create one, then change its type to MANUAL and then write what you want.
Be careful in that case to respect the good number of parameters in the request specification.

a DELETE request that looks like this:
DELETE From MyTable where FIELD = %SQLPAR0%
Produces a function named R_nnn_Delete() where nnn is the request number.

The use of this function is

Tac(
Var(IndiceToDelete),
R_nnn_Delete()
)

The Call stack should contain the parameters of the Delete.

The DELETE VALUE type is reserved to delete records with the key = the unique ID of the Table.
Every table must contain a AUTO_INCREMENT field, other tables may refer to that field as a reference.
So an other function is produced: it is called R_nnn_CrossRef() and checks that no other table refer to the record which is deleted.
You can use this function independently but it is always called before a delete occurs.

The DELETE Type opposed to a DELETE VALUE is also delete BUT with no CrossRef check. Use it with care!

Updates a session variable with the 2nd last value contained in the call stack.

Example: when the user logs in, he is in a group but if you want to give the possibility to a user to change his group dynamically to allow some functions according to the context, use this type of
function:

Tac(
Var(NewGroupValue), SetSessionVar(xxUserGroup),
Home()
)

Now, the user will have the menus of the group number contained in the variable NewGroupValue

These functions are set to work with date and time.
Note: I suggest that one creates a table with a calandar, fill it once every five or ten years and work on these values instead of going on computing always the same things.

add n seconds to the execution of an interactive function. A SetTimeLimit(0) (no limit) is always called before a batch function.
Syntax
setTimeLimit(10) // adds 10 seconds to the php time limit, see the php doc for this.

Executes a function and continues the execution without submitting.
It is a kind of an "Eval" function.
Example, In the little CRM, in the sub window that contains a list of the other user that have a contact in their list, I want to keep track of the list filter the user enters ( criterias ). But as
it is in "only" a sub window, I don't want to keep track of this in a session variable or any other method.
So in the first list I Build this string :

OutputBuffering( // start buffering
Tac( // do the job
Var(RFileContent),
PhpEvalNoReturn(), // I want to save the result of this action
OutputBufferingGetContents(), // I call this, the VarStack now contains the output
SetVar(WFileContent,1) // and I save it in a variable
a0_File(
FileName(CSSFile),
FilePtr(fpw),
Action(w),
Do(
a0_WriteVarStackInFile(WFileContent,fpw)
)
)
)
)

As I do not like ODBC, I prefered do this convertion program in VB and work directly in MySql
First, check that you have something like this in the visual basic project library list ( tools/references )
Then create a new module containing the code under and read carefully the first 10 lines of comments