MyPitSelf
Welcome to MyPitSelf


 English(US)  Français(FR)
 Site map


This documentation has been produced with MyPitSelf00816

   Welcome to MyPitSelf

MyPitSelf© is a tool to write information system linked to databases. Its design allows the reverse-engineering of the programs

It is an information system like an other but instead of dealing with bank accounts, mails, websites, process ... it deals with programs and databases.

Like the other Systems, one can always think of a new function to implement, there is no limit.

And what allows a System to be able to evolve without limits is linked to the recursivity principle which says that by feed-back on all or a part of the initials elements, a small number of initial elements are enough to build an infinite serie of elements.

Reverse-ingenering is a recursive process. MyPitSelf is a possibility to implement programs with this principle.

Keeping this way of thinking, the first program written with MyPitSelf is MyPitSelf itself (it doesn't seem important but it is, really).

This principle is implemented with:
- A method to resolve the paradigme of the access to the data in database.
- A language which uses this method and which also allows to put the sentences as data and back.

A part of this documentation is not too technical ( see general presentation ), the other chapters are.


MyPitself uses MySql, Php, SVG, Apache, HTMLArea, linux, firefox, Win2K/XP/IE6/7, and last but not the least itself .

The name MyPitSelf comes from MySql, Php and itself


. . . .


General presentation


- When it is complicated...

I had a problem when I had to maintain or develop programs with data designs like the one presented underneath:


Click and look at the picture during 5 seconds, no more Use the button on top of the new window to close it.

In general, you have seen boxes (data) and arrows which link them (connections between data). The problem was that this was becoming too complicated for me because the data and their connections were too numerous.

In this case, one calls colleagues and does big projects, costing a lot of time and the users often end unsatisfied.

But the user wants more because there is the permanent threat that customers will to go to the competitors if a strategic new function cannot be done, immediately.


- ...one find solutions...

In this case one updates the programs and now, one can really start to enjoy the work because with the appreciation of what the designer understood, and the consideration of what the programer intended to program we have to tell the user that the job will be done in x days for a price of y$. This has always been, for me, a task between a probability level (It should fit in these constraints) and a mystic level (Hope it will work).

So, as I didn't like this situation, I started to develop a tool to help myself.

I went on and as the program grew up, I reached the conclusion that one had to industrialize the development of the programs. To do this, the design stage and the writing stage of the programs had to be industrialize.
And to do this, I reached the second conclusion that programs had to be able to be reverse-engineered by it's own means.

But I had to find the way to do it.



- ...build them...

As one is never better helped than by one self, I built MyPitSelf . As the reverse-engineering is set up and the first program done with MyPitSelf is MyPitself, I think that the foundations are not too bad. The data model you have seen above during 5 seconds is the MyPitSelf data design !

Once I asked a teatcher in science history and science philosophy what was the limit of this development. He ansewered by the sentence you have read upper about unlimitted systems.

Practically, the limit of the system is bordered by the computer speed and memory but at least, it is far enough now.



- ... and talks about them!

Simple programs can be set up fast once one knows the development environment. But it's not all that obvious because it's different from what I have seen before. (You have been warned).

One can also make some more complicated things, for example MyPitSelf is not simple. It's a development environment which contains multi user access with rights, multilingual, multibase, with several environments ( development, tests, production), backups, documentation with screen copies, etc ...
I have used MyPitSelf to build programs with other users than myself and data designs that looked like these
.

I started to use the reverse-engineering to maintain MyPitSelf: for example, I once defined the use of a function which was not very clean and I wanted to update all programs to change this. As I used this function very often, I wrote a program in the MyPitSelf language to do this. MyPitSelf can maintain MyPitSelf ! As this program has already been written, it will not be too complicated to update it, if I have to write a modification on an other function.
Some people also call this refactoring.

An other example comes when one renames a field in the database. In this case, all function that use this field are treated to replace the old name by the new one.

What follows on this web site is more serious stuff because I explain how all this works. These explanations can make you believe that I contemplated before I proceeded. As a matter of fact, in the whole process actions have preceded the thought process. I prefer a tool that works rather than a concept that does not work.

There is still work to do, some parts are still dirty but now, I'm not afraid to clean up, and I am sure I will be able to benefit from it.

Actually, at the moment, I am setting up the environment to work with ajax, you will see my first attempts here.


Now, let's go to work !



- How ?


- - The core

The a part of the core is written in Php, the rest is written in the MyPitSelf language.

The programs written with MyPitSelf are done with the MyPitSelf design with :

- A "system" database containing the description of your system (databases, functions ...)

- One or more "data" databases with the datas of your program.




- - Define the data

You start by defining a working environment ie databases (fields, tables, indexes, links between data ...) and other features (constants, user rights, menu ...).

Then you generate simple SQL requests with the help of a tool that keeps the request parameters in the system (type of request, tables and fields of the request).

Some request are used to see the data (SELECT of a certain value or SELECT of a list of values).

Others are translated to functions that you can use in the MyPitSelf language (SELECT, INSERT, UPDATE, DELETE).

This is where the database paradigme is resolved: as the access to the data is done with functions and these functions are used in the programs, there are no SQL request in the middle of the programs.



- - Programs

A language based on function calls is used to write functions in source format. It uses usual features of other languages (variables, tests, loops, files/IOs, ...) and the functions produced by the requests.

This language is compiled and interpreted for interactive programs.

After source parsing, the system produces a table format.

The table format can be put in the database to be computed (reverse-engineered). Functions become data.

The system can regenerate the source format from the table format.

Out of the table format, the system produces executable code (in php today).


The difference with an other language is that the table format of the program which is the result of the parsing is available and can be treated with the means of the language.

It is like if you were the person who had written the compiler and so you would know how to write the parser, and, at the end of the parsing process, you would be able to rewrite the source.



- So What ?

So, I think that MyPitSelf resolves ( and will resolve ) some problems in information technology:



- - Complex treatments

Problem:

An application evolves in two directions: data to maintain and function to give. Today one can add data ( for example if you have 50 or 100 emails in your email box doesn't change many things ) but to add a function is less evident ( for example the sum of mails from Paul and Jack )

The need of complexity requires an industrial treatment. If the code checking is done by humans, some bugs will probaly appear goes in the programs


Answer:

When the basic functions on data are set up, the arrengement of these function to give more complex functions is easier to set up if we consider them as operations on data ( add the mails from Paul to the mails from Jack ).

If MyPitSelf, functions are transformed as organized as data in database and a data check is a current operation that can be done whith the right program.



- - Adaptation

Problème:

The data to manage are defined with a model and some rules that are justified during the primary design and according to the person who does the design.
But the resultant system must evolve in the time because during it's use some new functions are neded.
And furthermore, some parts that were important during the primary design become less important and some new ones become more important. In this case, the primary design must evolve to adapt to these new parts.

The important point is not the primary design but its flexibility and the possibility to use the existing parts.


Réponse:

The first system done with MyPitSelf is itself. First there was only the core then data heve been added then functions on these data, then the core has been updated and so on. In othe words the first data and system design has evolved along its growing. Systems done with MyPitSelf grow with the same logical way.

Today the data are enough for the development in the current version. The functions needed to build a development environment represent a good part of what one can imagine to build an information system, but some new needs like statistics or graphical outputs may be needed. Once they will be inserted in MyPitSelf, the other systems will be able to use them.



- - Conclusion

MyPitSelf is good enough even if it is only version 0.8 because the reverse-engineering is ready.
This means that if MyPitSelf Evolves, programs built with older versions will follow the new versions.



- Work frame

95 % of the developments are done via a web browser, with only the administrator having access to the server

It is multilingual at the system level, MyPitSelf is in English (well, my English) and in French

It is multilingual at the program level, the programs one develops can be seen in the languages the user selects

The functionnal documentation of your programs is facilitated due to the reverse-engineering and


The user rights management is in the core and can be extended to match your program specification : user rights on the menus, on the functions ...

It helps the conception of applications based on data designs with many links.
Screen copies

These screen copies come from the development example given under.
MyPitself lets you record the pages where one goes to, for example, create the software documentation.

Request generation: .

Function creation: .


Technical stuffs


- What is MyPitSelf ?

MyPitSelf is a system to develop and maintain programs and data in a database.
Each development has its own environment with:

One "system" database containing:
- the description of the data,
- the source of the programs,
- a list of settings like constants, working directories....

One or more "data" databases containing the data to maintain.

During the development, environments are included in the main environment.

After the development mode, one can produce a set which is independant of the main environment.



As a developer, with MyPitSelf, you will build the environments for other programs and fill the "system" databases of the other programs.

Its target is to develop multi-user programs so there is a user authorization context with password entry.



- Why MyPitSelf ?

Three main reasons:

1°) Databases are good to store and use data. They can also be good to store and use programs. The programs had to be written in a way that they can be organized in a database, so that they can be linked to the data they compute. That is why there is a language. This also means that programs are considered as data, consequently, one can treat programs like data.

2°) Once the data are defined, the programs compute them. In this system, the first step is to define all the data needed, after which the programs can be written. The original types of data are those given by the database.

3°) The first program done with this system is the system itself because if this system can organize and compute any data, it can organize and compute a system to organize and compute data.

This explains the loop in this image



- How is it done ?

Thanks to PHP, MySql, Javascript and Apache with Linux/Win2K on Firefox/IE.

The tools used are mainly MyPitSelf, The W2k NotePad, and PhpMyAdmin.
Lcc has been used to write a program to launch Batch jobs, It is an adaptation of mikehup.exe written by Michael Kohn (naken@naken.cc), Web page: http://www.naken.cc/

I use SVG to draw the tables with the links.

PHP us used to write the basic functions.

All user functions should be written in the MyPitSelf language. The basis of this language is:

It is also based on:
Note on the translation: although I'm french, I started to write this software in english afterwhich I added the possibility to have a localised ( french in my case ) version on-line, so I could write in both languages, especially this documentation.
Some chapters have been written directly in french, then translated into english. For others, it is the opposite. Mark has corrected a part of the English translation, The good english comes from him, I assume all the errors.
As a result of time constraints, there are sometimes differences in documentation but I think these are of minor importance and you will know how to deal with them.


I will will concentrate on the French version and the English version. If other contributors accept to translate this software in other languages, I'll be able to propose their traductions in the distribution.
Later in this documentation, ( chap How TO'S ), I talk about the translation.


- State of MyPitSelf

Never Finished because I always want to add some more functions! But good enough to have some production programs.

Currently, functions like versioning, testcase scenarios, automatic documentation, Internationalisation ... that I have started but they are not achieved yet.
At least, the existing ones allowed me to do what you are going to see ( if you go on ).

I can't tell you when the next version will come out because I can't do this at 100%.

Now, let's see what it looks like.



- An example


- - Data

Suppose you have a data model with a table of information about people (names, age etc.).

Also suppose that you have generated several requests with the system, including the one which has the number, say, 1012.

SELECT T0.Id,T0.Name,T0.Age FROM $Data.People T0 WHERE T0.Age <= %SQLPAR0% ORDER BY T0.Name ASC A function called R_1012_Select() has then been generated and it takes one parameter which is the age (xxx).

The system must generate the requests thanks to your specifications because all the parameters (tables, fields, conditions, sort orders) are stored in the system.

Then, the system can generate the SQL sentence and the function using this sentence


- - Program

A possible use of this function could be to output all the people whose ages are >= 30.
This will give a program which looks like (comments are preceded by //) :

Tac(                // Take and call: put values in the call stack and/or call functions.
 Cst(30),           // constant 30 pushed in the call stack
 R_1012_Select(     // select list of these people (1 parameter xxx taken from the call stack)
  Do(
   Take(T0.Name),   // Pushes the name in the call stack
   out(1)           // displays the first element contained in the call stack
  )                 // The name is popped here
 )
)                           
Remarque: lines breaks are ignored, one can also write this function like:
Tac(Cst(30),R_1203_Select(Do(Take(T0.Nom),out(1))))
Comas are not mandatory after ), an other way to write this function would be : Tac( Cst(30) R_1203_Select( Do(Take(T0.Nom),out(1)) ) ) Blocks comments are delimited by /* and */ , they MUST start at the first column and can be nested.


- - Table program

This program has this table format: :

Ind Function # Parent # Order In
Parent
Function
Name
Function
Type
Number Of
Children
Level C1 C2
0 0 -1 0 0 INIT 1 0
1 1 0 1 Tac formula 2 1
2 2 1 1 Cst formula 1 2
3 3 2 1 30 Value 0 3
4 4 1 2 R_1203_Select formula 1 2
5 5 4 1 Do formula 2 3
6 6 5 1 Take formula 1 4
7 7 6 1 T0.Name zone 0 5
8 8 5 2 out formula 1 4
9 9 8 1 1 Value 0 5

With this format, a program can analyse and identify the treatments with the data implied because all information about request #1012 are stored in the system.

In other words, one can reverse-engineer this program.

If you put this table format in the database, you can update the records with a program. Then, the system can regenerate the source format.


- - Source

<?php
function f_5001(){
 global $XVS,$XCS;  // variable stack and call stack
 $xxSI=sizeof($XCS);  // call stack init pos
 $xxSC=0;  // Stack push count
 //===== Start of function =====
 //===================
 $req4 = "
 SELECT  T0.Nom  FROM  `Gens` T0
 WHERE  T0.Age<=30
 ORDER BY  T0.Nom ASC " ;
 //===================
 $result4=mysql_query($req4);
 if(mysql_errno()==0){
  while($mpsrow4=mysql_fetch_row($result4)){
   echo '<span class="DBG">'.$mpsrow4[0].'</span><br />';   // output
  }
 }else{
  return(xxErrSql('1203_SELECT',mysql_error(),$req4,$xxSI));
 }
 mysql_free_result($result4);
 //===== End of function =====
 return(true);
}
?>
This example is quite simple but you will see by a click here something which is not: it is one of the function which does reverse ingineering of the execution of a program, it updates the table format of the function.



- Installation

I assume that Apache (1.3.29), Php (4.3.3), MySql (4.0), firefox or IE(6.0) are running fine on your system. The versions numbers are the one I currently use but I suppose that it will work with newer versions.

I assume that you know a minimum on these software and particulary the way to make them run together.
If this is not the case, please see the enormous amount of documentation about them.



- - Unzip

There are two files to Unzip:
The mypitselfw ( Web files ) to unzip in the htdocs folder of the web server
The mypitselfp ( Program files ) to unzip somewhere else but not in a htdocs subfolder.

On a linux system, you should thew execute these commands:

cd /var/www # assuming that you have put the folders mypitselfw and mypitselfp in /var/www
chmod -R o+w mypitselfp
chmod -R o+w mypitselfw
cd mypitselfp
chown root:root batch_linux.exe
chmod -R o+x batch_linux.exe



- - Php and Apache


- - - Php Configuration

The use of php.ini-recommended given with your php installation is strongly recommended
Anyway, if you use something else at your own risk, at least check that that the settings below are:
register_globals = Off


I use the setting
display_errors = on
display_startup_errors = On
error_reporting = E_ALL
Even if those settings are not recommended but it is for debuggings reasons.



- - - Apache Configuration

I assume Apache/php is running on your system.
Add this setting to go directly to the index.php

<IfModule mod_dir.c>  DirectoryIndex index.php </IfModule>


- - MyPitSelf Installation


When you tried to connect to the first screen, you saw a screen like this one

If this is not the case, something went wrong. Try to re-install it, deleting the folders and the database.

MyPitSelf installation.
Enter here the connection string to mysql
Enter here a valid user name
to access to mysql
Enter here a valid password to access to mysql
Enter the full name ( path included ) of the file
MyPitSelf root web path.txt
( It should be already filled )
Use the button to point on the file
MyPitself root program path.txt
( It is in the MyPitSelfP directory )
Database initialisation
Create database Delete database






If you have entered correct information in the fields and then have clicked on Create database and after a while you should have seen this screen

MyPitSelf installation.
Enter here the connection string to mysql
Enter here a valid user name to access to mysql
Enter here a valid password to access to mysql
Enter the full name ( path included ) of the file
MyPitSelf root web path.txt
( It should be already filled )
Use the button to point on the file
MyPitself root program path.txt
( It is in the MyPitSelfP directory )

Database MyPitSelfxxyzz created successfully. you can go to the menu.

or you can Delete database




If you did see it, it is all right, you should obtain a screen that ask you a user name and a password.
If this is not the case, well, something went wrong, try to reinstall it, deleting the folders and the database.


- - First Loggin

Click on this button: Go to MyPitSelf
You should see a window asking you for a user name and a password

Enter 1 in both fields and click on the "Enter" Button. Now if you see a window that looks like the one below, you can be happy :).





MyPitSelf




On this screen, there are several buttons in a menu bar that lead to number of lists.
You can click on them if you want but please, for the moment, avoid clicking the non-menu buttons.

Let's look at the 3 first options :

The button: allows you to come back to the initial screen.

The button: allows you to come back to the previous screen if it was a list or a "view" screen ( a screen to see informations ).

The button: allows you to quit. Try it now and re-enter 1/1 as user/password to come back to the initial screen.

You will see in examples to see how to use MyPitSelf some screen copies containing buttons with a standard meaning:
: New element
: Duplicate an element
: see an element
: update an element
: supress an element
: properties of an element
: Move an element







- Generated documentation

Out of the informations you have entered to create your program, MyPitSelf can generate a technical documentation
Click here to see it.



Examples


- First example: world

It's a programme to see the data from the "world" database avaible on the MySql website.

The database design is this one.


Click here to test this.




- Second example: CRM

This program is a little CRM for IT services providers to give the possibility to client companies to manage their own contacts.

Every company will have a main user called manager in the rest.
The manager creates the contacts ( first name, name ....)
The manager defines informations that will be linked to the concacts according to the company needs.

These informations are two types:
Event: it is a meeting, a meal at one date.
Relation: it is a fact concerning the contact like he is important, medium, small, he speaks french, english, or italien ...

The list of contacts is unique for every company, and it will be shared between the company users with relation with the contacts.

The manager defines the users ( login, name last name, password ).

The user will have a list of contacts that he will pick from the list of contacts of the company.

For every contact, he will be able to add relations or events that the manager hed previously defined.

A contact can be shared by several users.

A request system allow the user to list among his own contacts the ones that satisfy certains relation. The result of these requests can be combined with AND, OR, NOT, XOR functions.

The manager can do requests on all contacts of the company.
The data design is the one under.



You can see the general documentation ( normaly there is one specific for every type of user ) clicking here .

If you want to try it online, send me a mail with the contact page of this site and I will send you a login/password. This programm can be reached here .

It's only a little CRM but you have seen the possibility of MyPitSelf.

I didn't want to load this program with many buttons but it's quite easy to add for example the list of user that use a contact from the contact file.

One can add also company tables, links between companies and contacts and many other things that require a little more programming.

A bientôt.



- Third example

Now we are going to use this examples to see the use of this system.
The aim is to build a program in this environment.
There is a minimal set of explanations. Don't worry if you don't catch all of them, it will come later.
The project approach will have three different layers :

Organisation layer ( Client needs )
The client wants to have a system to do his task list. Each user of the system will be able to put some new tasks in the system with a name and a priority level. The priority level is a number and each user will be able to see the task list according to its priority level.
The client also wants to find tasks according defined sequences ( word match research ).
Some users ( eg managers ) must be able to see the tasks of all other users but most of then will see only their own tasks.
A user can modify each task ( priority and text ), add or delete one.

Functional layer ( what do we have to do )
A Task table with a user ID, a task name and a task priority.
A user table with the user ID, his logging name, first name and last name.

We will need to have a function to display a list of tasks according to its priority and according to the fact that the task contains a certain word. From this list, one will be able to create new tasks, modify existing ones or delete them.
An other functon ( manager ) will display a task list with the user name.
So according to the user profile, differents menu will be displayed.
User: See my tasks Manager: See my tasks, see all tasks

A super user will have the possibility to enable other users and to assign them a user level ( manager or user ).
A manager will be considered as a user for his ( or her ) own tasks.

Technical layer ( how are we going to do this ? ).
See the next chapters.

Comment: During the modification of a record, a lock is set up and during the next procedures, you might close windows during a modification and so, the lock will remain.
To take it off, go to the Profil menu then choose the option See the locks then click on the Unlock button.



- - A new environment


Click here to open a new window on MyPitSelf , enter 1/1 as username / password

The first thing to do is to create a new environment.

Note: for the moment, I have not worked enough on the privileges on the database so there is not a fine tunning of them.
The way it works is to define for each environment a mysql user/password ( or have always the same one ) and authorizations are set um for this user.
I advise you to use MyPitSelfDev, it works !

To do this, click here and perform the actions described.

To create a new environment means to create directories and a system database. ( look in folders mypitselfp and mypitselfw )



- - A new manager

Click here to open a window if it's not already open. on the MyPitSelf environment and log in as 1/1.

We have to create a manager who will have the ability to use the new environment.
For the moment, there are 3 profiles in MyPitSelf:

so we will have to To do this, click here and perform the actions described.

A user has been created, his name is m, his password is 1.


- - Start to develop


- - - Initialize the environment

Cliquez ici pour ouvrir une nouvelle fenetre si ce n'est déjà fait
Quittez l'environnement principal si vous êtes connecté en tant qu'utilisateur 1/1
et connectez vous en tant que m/1

Comme vous vous êtes connecté en tant qu'utilisateur m, vous ne voyez pas les mêmes menus que précédamment, en particulier, les menus permettant de gérer les utilisateurs sont réservés au super utilisateur.

En revanche d'autres menus sont apparus et vous permettront de développer.
Il faut tout d'abord créer une image de la base de donnée. En fait cette image a déjà été créée lors de la création de l'environnement. Vous pouvez la voir en cliquant sur le bouton base du menu.

Puis il faut donner à cette image une existance réelle c'est à dire créer réellement la base dans MySql.
Pour ce faire, exécutez les actions que vous voyez en cliquant ici .

Remarque: La base contient déjà 2 tables: Une table utilisateurs et Lock ( verrous ).
Ces deux tables sont créées car MyPitSelf est conçu pour travailler en environnement multi utilisateur.
Elles peuvent être supprimées ou modifiées mais pour l'instant, nous n'allons pas y toucher.



- - - Create a table

Puis il faut créer la table des tâches. Cette table est rattachée à la base et contient :



Des types de données existent déjà, nous allons les utiliser sans créer des nouveaux types. Voir le bouton donnee du menu.

Pour ce faire, exécutez les actions que vous voyez en cliquant ici .



- - - Create a list request

Maintenant il faut créer une requête permettant de lister les tâches. Elle resemblera à:

SELECT T0.ID,T0.Nom,T0.Priorite,T0.xRefUser FROM $Data.Taches T0 WHERE T0.Priorite <= %SQLPAR0% and T0.Nom LIKE '%%SQLPAR1%%' and T0.xRefUser = %SQLPAR2% ORDER BY T0.Priorite DESC , T0.ID DESC LIMIT $xxxlistStart , $xxxlistCount

%SQLPAR0% et %SQLPAR1% sont les deux critères de recherche possibles des tâches,
%SQLPAR2% limite la recherche à un utilisateur donné.

MyPitSelf contient un utilitaire permettant de générer les requêtes sur la base de donnée.

Nous allons l'utiliser pour créer une requête de type SELECT LIST.
Ce type de requêtes a été défini car il permet de générer des instructions propres à l'affichage d'une liste.

Pour l'utiliser, exécutez les actions que vous voyez en cliquant ici .

Le résultat de cette action, visible en cliquant sur le menu Requête est une requête SQL ayant un Code 1201 dans notre cas.

Nous avons coché le champ Hidden et Constant car lors de l'affichage de la liste des tâches, il ne faut pas afficher l'ID utilisateur ( c'est l'utilisateur en cours ) et le critère d'affichage des tâches est pour l'utilisateur en cours donc constant.



- - - Create a menu

Maintenant, il faut créer un menu permettant d'afficher la liste des tâches.
Ceci passe tout d'abord par la création d'une fonction écrite en langage MyPitSelf.
Cette fonction sera ensuite attachée à un menu.
Pour ce faire, exécutez les actions que vous voyez en cliquant ici .
Utilisez un copier/coller pour éviter de réécrire la fonction.
Un petit mot ici sur le langage MyPitSelf puisque cette fonction a été écrite dans ce langage:
Cette fonction permettant d'afficher la liste des tâches de l'utilisateur

Tac( Cst(999999999), // paramètre priorité de la tâche Cst(), // paramètre Nom de la tâche ( chaine vide ) VarG(xxUserCode), // Code de l'utilisateur ( variable globale ) Cst(3), // 3 paramètres a0_list( // afficher la liste basée sur ... Sql(1201) // ... la requête 1201 ) ) veut dire:
Tac ==> Take and Call: c'est l'INSTRUCTION principale de ce langage: Elle permet Ici, on met des constantes dans la pile d'appel ( 999999999, chaine vide et la valeur 3)
On met aussi une variable globale initialisée par le système. Elle représente l'unique ID de l'utilisateur.
La fonction appelée est a0_list avec un paramètre qui est le numéro de la requête à appeler.

L'instruction Tac sait reconnaître les fonctions permettant de mettre des variables dans la pile et celles exécutant des actions.
Ce langage est basé sur des fonctions qui peuvent être imbriquées les unes dans les autres ou appelées séquentiellement.
cette fonction peut aussi s'écrire de la façon suivante:
Tac( Cst(999999999), Cst(), VarG(xxUserCode), Cst(3), a0_list( Sql(1201) ) ) La fonction a0_list par définition prend 1 ou plusieurs paramètres dans la pile de variables, le premier paramètre ( 3 dans notre cas ) indiquant le nombre de paramètres à prendre dans la pile ( 99999, chaine vide, code utilisateur.

Vous avez compris que // indique un commentaire.



- - - Créer les fonctions

Maintenant, il faut créer une fonction permettant d'ajouter une tâche.

Nous allons utiliser l'outil pour créer une requête de type SELECT VALUE.
Ce type de requêtes a été défini car il permet de générer des instructions propres à l'affichage d'une entrée dans la base. Pour ce faire, exécutez les actions que vous voyez en cliquant ici .

Enfin, nous pouvons créer la fonction de type LISTTOP rattachée à la liste affichant la requête 1201
Pour ce faire, exécutez les actions que vous voyez en cliquant ici .

Enfin la dernière étape sera de regénérer toutes les requêtes, de compiler toutes las fonctions, d'établir la langue par défaut du programme et de créer les utilisateurs initiaux ( 0 = tous, 1 = super user )
Pour ce faire, exécutez les actions que vous voyez en cliquant ici .

Finalement, on peut commencer à tester l'application qui contient maintenant quelque chose.



- - Testing


- - - Add Todos

Cliquez iciet choisisez le bouton Test pour ouvrir une fenêtre sur votre nouveau programme en vous connectant avec le nom/mot de passe 1/1.

Maintenant, vous êtes le super utilisateur du NOUVEAU PROGRAMME, vous pourrez définir les autres utilisateurs et leurs droits tout comme vous avez défini un nouvel utilisateur dans l'environnement principal.

Tout d'abord, il faut savoir que par défaut, le super utilisateur est aussi un utilisateur normal et peut avoir accès à tous les menus.Si lors de la création du menu ( plus haut ) , vous ne cochez pas la case "pas pour super", le menu est disponible pour le super utilisateur.

Maintenant, nous allons tester le menu tâches en cliquant ici .




- - - Ajouter des utilisateurs

Puis nous allons ajouter deux utilisateurs en les rattachant à des groupes d'utilisateurs manager et utilisateurs qu'il faudra ensuite créer dans l'environnement de développement.
Pour créer ces utilisateurs, exécutez les actions que vous voyez en cliquant ici .




- - - Ajouter les groupes

Puis nous allons définir deux groupes d'utilisateurs ( manager et utilisateurs ) dans l'environnement de développement
Les actions à faire sont celles que vous obtenez en cliquant ici .

Pour leur assigner des menus, les actions à faire sont celles que vous obtenez en cliquant ici .



- - Add functions

Return to the development environment clicking here and log in as m/1.

We will add functions to be able to see, update, duplicate or supress a task.

To supress a task, we need to create a request with a DELETE VALUE type. Look the request number created, we will use it in the functions.
Then we will create functions with LISTFUNCT type.
To do this, perform the actions you see when you click here .

Now we are going to test these functions
Click hereand choose the Test button to open a window on your new program, log in as user/password m1/1.
Then test doing what you see when you click here

Voilà, the first part of the organisational part is finished, now we will add functions to allow the manager to see all tasks.



- - A New request.

Now we will built a menu to see tasks of all users for the managers.
To do this, we will have to create a request to list the tasks and the name of the user who has created this task.
This request will have two tables : the User table and the task table.

And, finally, we will create a new function and a new menu attached to this function.
Perform the action you see when you click here .

Then click here and choose the Test button to open a window on your new program, log in as 1/1.

Attach the new menu to the manager group performing the actions you see when you click here .

As you are user 1, you can try to click on the button of the menu now.



- - linked table

The client wants to add functions:
From the task list, the mananager should be able to
Create a task for a use other than himself.
Update a user task and particulary, change the user of the task.

How can this be done ?

I think you understood that MyPitSelf uses linked tables.
For example, during the development, you have noticed that we have attached a menu to a function, a table to a database, a field to a table, a menu to a group of users, etc ...
We are going to create a link specification.

The link here is that a task is attached to a user.
When a manager has to give a user task to an other user, he must be able to choose a user in the existing user list ie the user table.

We will have to create

Connect to MyPitSelf with the user m/1 and perform the actions you see when you click here .

Connect to MyPitSelf with the user m/1 and perform the actions you see when you click here .

Now, go to your program, with user/password m/1 and perform the actions you see when you click here .

Now we are going to add the function ( type LISTTOP ) to create a new task.

Connect to MyPitSelf with the user m/1 and perform the actions you see when you click here .

Now go to your program, log in as 1/1 and do the actions you see when you click here

now, log out and log in as user u/1 and you will see that this user has a new task.


- - Conclusion

These examples have showed you how to develop with MyPitSelf and a part of its functionnalities.

As MyPitSelf is mostly done with MyPitSelf, the best example of developement can be obtained when you connect to the MyPitSelf environment with user/password 1/1 .
Then click on the "tool" menu and then choose the button "Set or unset developing mode for MyPitSelf".
All menus will be seen then and you will be able to see the core.
You also can use the button "See/hide function call" in the "profile" menu to see which requests/functions are used.

An essential point in MyPitSelf is that fonctions written in its language are parsed to units that are visible using the button print facing the source of the functions in the function list ( try it in front of function 4003 ).
The ressult of this parsing is a grid that can be put in a database table.
Records of this table can be analysed and updated with the MyPitSelf Language.
One can then reverse ingeener the functionnalities on this grid and regenerate the source.
See the chapter "language reference" for more details about this subject.

See also the next chapters.

I haven't mentioned many other aspects, I have to enhance this documentation but I'm pretty sure you got the main points.
MyPitSelf will evolve because there are still functionnal gaps, but as nearly everything is in a database, including programs, that programs and data are linked and programs are finally considered as data to treat , the "only thing" to do is to add data and treat them.


When one has to develop data models that look like the MyPitself data model you have seen on the home page, it is nice to have a tool to help.

I think MyPitSelf is cool to deal with data models with many links.



Language


- General

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-100INIT10
101fformula21
211gformula12
321xzone03
412hformula12
541yzone03

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

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 )

hello world
1 represents world
2 represents hello

Some variables are globals ( particulary predefined variables )

The hw() function displays the content of the call stack ( "hello, world" )
the pvs() function displays the content of the variable stack. ( print variable stack )


- - SetVar

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 )

Examples:

SetVar(MyVar01,Cst(Hello),Chr(39),Chr(32),Cst(world)), // puts "hello, world" in MyVar01. SetVar(MyVar01,Cst(25.5)), // now, it contains 25.5 SetVar(MyVar01,Cst(0)), // now, it contains 0 SetVar(MyVar02,Cst(ACombinedvar),Var(MyVar01)), // MyVar02 contains ACombinedVar0 SetVar(Var(MyVar02),Cst(25.5)) // ACombinedVar0 is created as a new variable // and contains 25.5 SetVar(toto,Display(1000011)) // puts the content of the message n# 1000011 in toto


- - Predefined variables

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.



- - Operations on variables

They are basic because most operations are done using values in the call stack.

AddVar(xxxx,yyyy) Adds to xxxx ( must exist ) yyyy, yyyy can be: Cst(), Var(), n ( a value in the call stack )

SubVar(xxxx,yyyy) Subs to xxxx ( must exist ) yyyy, yyyy can be: Cst(), Var(), n ( a value in the call stack )

MultVar(xxxx,yyyy) Multiply to xxxx ( must exist ) yyyy, yyyy can be: Cst(), Var(), n ( a value in the call stack )

DivVar(xxxx,yyyy) Divide xxxx ( must exist ) by yyyy, yyyy can be: Cst(), Var(), n ( a value in the call stack ) If yyyy = 0, it returns false.

RemainderVar(xxxx,yyyy) xxxx % yyyy . If yyyy = 0, it returns false.

To test if a variable exist, use this kind of source : Tac( Test( Cond(IsSet(Var(MyVar))), // or Cond(IsSet(VarG(MyGlobalVar))) IfTrue( // do something ), IfFalse( // do something else ) ) )


- - Tac

Tac: pushes values into the callstack

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: onclick="document.XXFNCT.value='Tac( Cst(1234), out(1) )'"



- - Swap

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)) )


- - FillVar

Fills a variable with a value according to it's data type:
It is mostly used for ENUM and FLAG types
Example:

Tac(
 SetVar(DataType,Cst(1002)),
 SetVar(Value,Cst(1)),
 
 FillVar(Libelle,DataType,Value),  // Now Libelle contains 

 Ech(Var(Lib)),
)



- - DataVal

Tac( SetVar(ExternalRule,DataVal(InternalRuleName,Data(1034))), SetVar(out,Var(out),sp(),Var(ExternalRule),Cst(':')), )


- Numbers


- - Format a number

To put a number in the local format, do:

Tac( SetVar(Value,Cst(1234.567)) SetVar(DisplayValue,Num(Value,3)), // Display value contains // 1 234,567 in french format // 1,234.567 in us format )


- - Round a number

Tac( SetVar(R,Cst(0)) SetVar(Value,Round(Value,R)) )


- Control and call functions


- - Test

Tests a contition to execute or not execute a treatment

Test( Cond(xxx), [IfTrue(yyy),] [IfFalse(zzz),] ) where xxx is the condition: It can be a function.
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( out(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( out(I do not want to continue so I exit the program ), ReturnFalse() // this instruction stops the program returning false ) ) ) Example 3: SetVar(ValueToTest,Cst()), Tac( Var(ValueToTest), Test( Cond(IsVoid()), IfTrue( out(I DO want to continue ), ), IfFalse( out(I DO NOT want to continue ), Test( Cond(Funct(123456)) // writes in errorlog something IfTrue( ReturnFalse() // if we can't write in error log, BIG ERROR ) ) ) ) ) Test a function result: Tac( Var(TableCode), Var(FieldCode), Test( Cond(Funct(Var(T0TestFunct))), // Var(T0TestFunct) contains the function number IfTrue( Tac( // do something ) ) ) )


- - LoopVar

Loops n times a treatment.

LoopVar( xxxx, yyyy, Do(zzzz) ) where xxx is a variable containing the number of loops to do.
When the loop is executed, yyyy is set to the current loop number
zzzz is the series of functions

Example: SetVar(ValueToLoop,3), LoopVar( ValueToLoop,ind, Do( SetVar(Message,Cst('hello world '),Var(ind)), Tac( Var(Message), out(1) // outputs the 1st value in the call stack ) ) ) this loop displays hello, world 1 hello, world 2 hello, world 3


- - SwitchCase


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: Tac( Cst(0), SwitchCase( 0, out(OK), 1, Tac( DoManyThings(), out(OK) ), out(KO) // default ) ) outputs OK and continues

Tac( Cst(2), SwitchCase( 0, out(OK), 1, out(OK), out(KO) ) ) outputs KO, and continues

Tac( Cst(2), SwitchCase( 0, out(OK), 1, out(OK) ) ) returns false ( it's a bug because the case has not been considered )



- - Funct

Funct(xxxx) where xxxx is the number of the function to call
or xxxx = Var(yyyy) where yyyy is a variable that contains the function number to call


- - Comparison

Compares with the last value un the call stack

Equal(xxxx), EEqual(FALSE),EEQUAL(NULL) // does a type check ( === in php ) Greater(xxxx), Lower(xxxx), LowerEqual(xxxx) GreaterEqual(xxxx) IsVoid() IsNotVoid() IsNumeric() where xxxx is a constant or xxxx = Var(yyyy)
with yyyy = variable name

Example: Tac( SetVar(src,Cst('this is a . bug ;')), // SetVar(src,Cst('$temp="This correct";')), PhpTest(retour,src), Var(retour), Test( Cond(EEqual(FALSE)), IfTrue( out(KO), ReturnFalse() ), IfFalse( out(<br /><br />OK) ) ) )


- Files


- - a0_File

Opens and close a file after treatment. The syntax is:

a0_File( FileName(xxxx), FilePtr(yyyy), Action(z), Do(ffff()) ) where:
xxxx is a variable in the variable stack which contains the name of the function.
yyyy is a variable name which is created in the variable stack which will contain the name of the pointer to the file. This variable can be used in the ffff() function.
z : equals a ( append ) or w ( write ).
ffff : is a function name to call.

You don't have to close the file, it is called when the function is finished.
Example: Setvar(MyFileName,VarG(xxPtaW),Cst(hello.htm)), // Fills the variable MyFileName with // the the file name SetVar(MyFileContent,Cst(<HTML><BODY>Hello, world</BODY></HTML>)), // Fills the File content a0_File( FileName(MyFileName), FilePtr(MyFilePointer), Action(w), // the file is [re]created Do( a0_WriteVarStackInFile(MyFileContent,MyFilePointer) // file is written ) ) // file is closed here


- - a0_WriteInFile

Writes the content of a variable in the variable stack into a file.
Example:

SetVar(FileName,Cst('helloworld.htm')), SetVar(FileContent,Cst('hello, world')), a0_File( FileName(FileName), FilePtr(fp), Action(w), Do( a0_a0_WriteInFile(FileContent,fp) ) ) this writes a file "helloworld.htm" containing the string "hello world".


- - a0_WriteInSourceFile

Writes the content of a variable in the variable stack into a file adding a Begin Php Tag at the begining of the file and a End Php Tag at the end of the file.
Example:

SetVar(FileName,Cst('helloworld.php')), SetVar(FileContent,Cst(' echo "hello, world\\n" ;')), a0_File( FileName(FileName), FilePtr(fp), Action(w), Do( a0_WriteInSourceFile(FileContent,fp) ) ),


- - a0_ReadFileInVarStack

Read the content of a file and put it in VarStack. The syntax is:

a0_ReadFileInVarStack( xxxx, yyyy ) where
xxxx is the variable name which will contain the content of the file
yyyy is the variable name which contains the name of the file pointer
Example: To copy a file a into a file b, use this a0_File( FileName(SourceFile), // complete path FilePtr(sfp), Action(r), Do( SetVar(FileContent,Cst()), a0_ReadFileInVarStack(FileContent,sfp), a0_File( FileName(TargetFile), // complete path FilePtr(tfp), Action(w), Do( a0_WriteVarStackInFile(FileContent,tfp), ) ) ) )


- - a0_WriteInBinaryFile

Writes a file content as binary data, useful for copying images.
example: Copy the content of img directory which contains images

SetVar(FilePath,VarG(xxPaWr),VarG(xxDatB),Cst(/../)), SetVar(FileName,Cst(^.*$)), Tac( Var(FilePath), Var(FileName), a0_DirList( SetVar(FileName,3), SetVar(FileSize,2), SetVar(FileTime,1), SetVar(SourceFileContent,Cst()), SetVar(SourceFile,VarG(xxPaWr),VarG(xxDatB),Cst(/../),Var(FileName)), SetVar(TargetFile,VarG(xxPtaW),Cst(../),Var(FileName)), a0_File( FileName(SourceFile), FilePtr(SourceFp), Action(rb), Do( a0_ReadFileInVarStack(SourceFileContent,SourceFp), a0_File( FileName(TargetFile), FilePtr(TargetFp), Action(wb), Do( a0_WriteInBinaryFile(SourceFileContent,TargetFp) ) ) ) ) ) )