Minotaur RTM is a Vb.Net Source Code Generator.

With his native Language you can easely create fully functional interfaces.

Plug-ins PlugIns
New Features NewFeatures

SQL instructions can be written into code.


NEW Business Unit Rules:
Added the "Rule" command that allows you to enter all controls related to a record a single point in the program.
If used properly prevents insertions / logically incorrect updates / cancellations to your database.
But how does it work?

With each "check" you can specify the parameters. Its default is the record (Sender) caller.

Rule Anagrafico_Insert {
     Expression StopRule (ID) {ID < 1} "ID inferiore a 0";
     NotFound as IdDuplicato StopRule (ID) 
                {Select * from Anagrafico where ID = {ID} } 
                           "ID Duplicato (Impossibile).";
     NotFound StopRule (CodAnagrafico) 
               {Select * from Anagrafico Where CodAnagrafico = {CodAnagrafico} }
                          "Codice gia' esistente";
     Action {
      Sender.ID = @ as integer {select isnull(max(ID),0) + 1 from Anagrafico};
      Prepare Sender for Insert into Anagrafico;
      Console writeline "Inserito: " & Sender.ID;
     };
}


The "Rule" instruction can be declared in any of the source point.
It is composed of a number of directives (Specified even several times).
Each directive requires to verify the rule, then BE verified.
  • "Expression" corresponds to an "if" statement, and if you do not verify the valid rule.*
  • "Found" accepts a query-sql and to be verified should must return rows (useful for delete / update business unit).
  • "NotFound" to verify the rule should NOT return rows (useful for pre-insert verification).
  • "Action" runs a block of code.

The enforcement of the rule is for each positional verification. Specifying "StopRule" you can stop the process.

"Rule" is used in tandem with "CheckRuleFor <your record> Using <your Rule>".
<your Rule>.StringErrors contains all strings (if specified) errors, automatically enqueued.
<your Rule>.Errors is the collection of errors generated.

    If Not CheckRuleFor cAnagrafico Using Anagrafico_Insert {
      Console writeline Anagrafico_Insert.StringErrors;
    }




Auto-open/close db-connection.
If you don't specify an explicit "open connection" (MyDb.Open). RTM open/close connection automatically.
You can also specify a time-out connection that keeps on connection xxxx msecs since last SQL statement execution.

  Database Test AutoClose 15000;

After 15 secs database Test (if not used) is closed.

SQL Ticket
For multi-threading is availaible ticketing: create a sql stack statements (clearly slow execution perfomances).

All sources can be written with a simple notepad.

A simple charater-Forms designer allows you to render TextBox, Label, DataGridView, Button and many other objects.

Tested on Ms-SQL, PostgresSQL, MySQL

Quick start:

Make sure you have "administrative" privileges!
  • Download and unzip into "C:\RTM6" folder.
  • Open a DOS Windows (CMD)
  • execute:
    • C:
    • CD \RTM6
    • RTM6c -fixpath

(click on DemoMode)
  • close DOS
  • Open another DOS Windows.

Type on your DOS Windows:

RTM6c

If installation is correct you should see something like this:

Minotaur RTM Source Generator (r) - All Rights Reserved.
Version: 10 Rev. A (2016-08-09)
Notes..: Image processor (Beta), Record Clever (Beta)
Process terminated.



Classic "Hello, World!" ?

Just type:

Notepad HelloWorld.rtm

Type the following code:
Main {

    Console WriteLine "Hello, World!";   

}



Save File

Generate & Compile with:

Rtm6c -make HelloWorld.rtm

and finally execute with:

Rtm6c -execute HelloWorld

Database connections:

rtm6c -sqlconfig

(Refer to documentation "doc" folder)

Field type supported
  • String (Char, VarChar)
  • Decimal (Decimal, Double)
  • Integer (Integer)
  • Date (Date, Smalldate, DateTime)
  • Image (Image, Bytea..)
  • Boolean (bit)
  • Document (XML-object storage structure).

All types tested with Ms-SQL, PostgreSQL, MySQL (like-mode) .

Important:
String, Decimal, Integer, Date, Boolean when defined in a Record structure automatically transform NULL value into default.

Default values:
  • String = ""
  • Decimal = 0
  • Date = 01/01/1900
  • Image = Nothing
  • Boolean = False
  • Document = ""

Type Document

Use a varchar(max) to store it into db.
Document is special class. Contains in (XML format):
  • Name
  • DocumentData

Example:

Database TestRTM;

Globals {

  define Anagrafico Record
          Id         as integer,
          Cognome    as string,
          Nome       as string,
          Documento  as Document;
}

Main {

     delete from TestFile;   
          
     Anagrafico.Documento = array {"Doc1", "HelloWorld.Docx"};
     
     insert into TestFile values('TRY1', {Anagrafico.Documento});

     define cTestFile Record
            NomeFile    as string,
            FileData    as Document;

     select *
     into cTestFile
     from TestFile;

    /* messagebox cTestFile.FileData.Name;  */

     cTestFile.FileData.WriteDataToFile("HW1.docx");

}



Polling Folder
Special object. Polls a folder every xxxx for a specific pattern.
If a file is found execute code.

Example:

database Test;

Main {
    define MyDir as string = "c:\Tests";
   
    polling MyDir pattern "*.xml" named MyPoll every 3000 {
          /* FileName variable is auto-generated from polling object */
              MyDisplay(FileName);
    }

    messagebox "Hi!";
}

Sub MyDisplay(MyString as string) {
    messagebox MyString;
}



Record Binding

Example 1 (MyRecord is filled with contents of table MyTable):

Database Test;

Main {
    define MyRecord Record Binding
                  ID      as Integer,
                  MyDesc  as string;

    foreach DataRow MyRecord in @ as dataset  {select * from MyTable} {
   
    }
    messagebox MyRecord.Count;
}


Example 2 (using reflect statement):

Database Test;

Main {
    define MyRecord Record Binding
                  ID      as Integer,
                  MyDesc  as string;

    Reflect @ as dataset  {select * from MyTable} into MyRecord;
    messagebox MyRecord.Count;
}


Example 3:

Database Test;

Main {

    define cMyTableA Record like MyTableA;
    
    define MyRecBind Record Binding
           ID           like MyTableA.ID,
           FlagRead     like MyTableA.FlagRead,
           Description  like MyTableA.Description;

    foreach DataRow cMyTableA in @ as dataset {select * from MyTableA} {
       if cMyTableA.FlagRead = "Y" {
          AddRow MyRecBind;
          MyRecBind(MyRecBind.Count-1).ID          = cMyTableA.ID;
          MyRecBind(MyRecBind.Count-1).FlagRead    = cMyTableA.FlagRead;
          MyRecBind(MyRecBind.Count-1).Description = cMyTableA.Description;
       }
    }
}



Transactions?
Are availables. Database must be forced open.

dbTest.Open;

Transaction dbTest Begin;
Transaction dbTest Commit;
Transaction dbTest Rollback;

dbTest.Close;


...and How-to make a choose window?:

Main {

    Define RecInp Record 
           MyID        as integer,
           MyDesc      as string,
           MyStateID   as string,
           MyStateDesc as string,
           BornDate    as date;
           
    Form fExample07 open "Esempio07.frm" {
      
         When MyStateID.KeyDown {
            If e.KeyCode = Keys.F6 {
			   define RecState Record 
                      MyStateID     as string,
                      MyStateDesc   as string;
                      
			   Reflect Scelta("States", "Choose State", RecInp.MyStateID, 0, 0) to RecState;
			   RecInp.MyStateID   = RecState.MyStateID;
               RecInp.MyStateDesc = RecState.MyStateDesc;
	        }  
          }	   
          
          When BtnSave.Click {
               if Form fExample07 IsValid {
                  messagebox "OK SAVE!!!";
               }
          }
    
    } ShowDialog;

}

Function Scelta(quale as string, descrizione as string, Ricerca as String, Codice1 as integer, Codice2 as integer) as Structure {
  
   define RecRicerca record
          quale      as string,
          parametro  as string,
		  Codice1	 as integer,
		  Codice2    as integer;
		  
   RecRicerca.quale     = quale;
   RecRicerca.parametro = Ricerca;		  

   Form FormScelte open "Esempio07s.frm" { 
        Public Ritorno as Structure;
        When Me.Load {
		     me.Text = descrizione;
             AggiornaCursoreScelta(RecRicerca, Codice1, Codice2);
		}
		When parametro.ReturnKey {
		     if SelectedIndex FormScelte.griglia > -1 {
                RaiseEvent griglia.CellDoubleClick;
			 }	
		}
		When parametro.KeyDown {
    		 define posizione as integer = SelectedIndex FormScelte.griglia;
		     if e.KeyCode = Keys.Down {
			    if (Posizione + 1) <= (RowsCount FormScelte.griglia - 1) {
				   SelectedIndex FormScelte.griglia to {Posizione + 1};
				}
			 }
			 if e.KeyCode = Keys.Up {
			    if (Posizione - 1) > -1 {
				   SelectedIndex FormScelte.griglia to {Posizione - 1};
				}
			 }
		}		
		When parametro.EscKey {
		     Form FormScelte close;
		}
		When parametro.KeyUp {
		     AggiornaCursoreScelta(RecRicerca, Codice1, Codice2);
		}
		When griglia.CellDoubleClick {
			   switch RecRicerca.quale {
					  case = "States" {
                      /* Example with db
						   define lTabBandi Record like TabBandi;
						   select *
						   into lTabBandi
						   From TabBandi
						   Where IdBando = {SelectedItem FormScelte.griglia.IdBando};								  
                      */
                           define RecState Record 
                                  MyStateID     as string,
                                  MyStateDesc   as string;
                           RecState.MyStateID   = SelectedItem FormScelte.griglia.MyStateID;
                           RecState.MyStateDesc = SelectedItem FormScelte.griglia.MyStateDesc;
					       Ritorno = RecState;
					  }
			   }		     
		       Form FormScelte close;
		
		}
   }
   Form FormScelte ShowDialog;
   
   Scelta = FormScelte.Ritorno;

}

Sub AggiornaCursoreScelta(RecRicerca as Structure, Codice1 as integer, Codice2 as integer)  {

   define ricerca as string = RecRicerca.parametro;
   if Instr(ricerca, "%") = 0 {
      ricerca = "%" & ricerca & "%";
   }

   switch RecRicerca.quale {
		  case = "States" {
               /* Example with db ...
			   cursor CurScelta for
					  select IdBando, CodBando, DesBando
					  from TabBandi
					  where DesBando like {ricerca}
					  order by DesBando;
			   */
               Define CurScelta Record binding
                      MyStateID         as string,
                      MyStateDesc       as string;
                      
               if instr("ITALY", ucase(RecRicerca.parametro)) > 0 {
                  AddRow CurScelta;
                  CurScelta(CurScelta.Count-1).MyStateID     = "IT";
                  CurScelta(CurScelta.Count-1).MyStateDesc   = "ITALY";
               }
               if instr("USA", ucase(RecRicerca.parametro)) > 0 {
                  AddRow CurScelta;
                  CurScelta(CurScelta.Count-1).MyStateID     = "US";
                  CurScelta(CurScelta.Count-1).MyStateDesc   = "USA";
               }
               if instr("GERMANY", ucase(RecRicerca.parametro)) > 0 {
                  AddRow CurScelta;
                  CurScelta(CurScelta.Count-1).MyStateID     = "GE";
                  CurScelta(CurScelta.Count-1).MyStateDesc   = "GERMANY";
               }
               if instr("FRANCE", ucase(RecRicerca.parametro)) > 0 {
                  AddRow CurScelta;
                  CurScelta(CurScelta.Count-1).MyStateID     = "FR";
                  CurScelta(CurScelta.Count-1).MyStateDesc   = "FRANCE";
               }

               
			   Refresh DataSource FormScelte.griglia with CurScelta;
		  }   
   }

}







Esempio07.frm:
Screen "..." {

[lMyID         ][MyID     ]                     [BtnSave  ]
[lMyDesc       ][MyDesc                       ]
[lMyStateID    ][MyStateID][MyStateDesc       ]
[lMyBornDate   ][BornDate ]

}

Field lMyID             type Label & Text "ID";
Field lMyDesc           type Label & Text "Description";
Field lMyStateID        type Label & Text "State";
Field lMyBornDate       type Label & text "Born date";

Field MyID              type TextBox & allowed Integer & NotEmpty & fill RecInp.MyID;
Field MyDesc            type TextBox & upper & NotEmpty & fill RecInp.MyDesc;
Field MyStateID         type TextBox & upper & NotEmpty & fill RecInp.MyStateID & comment "[F6]: Choose state";
Field MyStateDesc       type TextBox & Disabled & fill RecInp.MyStateDesc;
Field BornDate          type TextBox & allowed Date & NotEmpty;

Field BtnSave           type Button & text "Save" & Image ImageSave & lines 4;



Esempio07s.frm:
Screen "..." {
[lricerca             ][parametro                                ]
[griglia                                                         ]
}
Field lricerca 		type Label & Text "Search...";
Field parametro		type TextBox & fill RecRicerca.parametro & RefreshOnKeyDown;


Field griglia		type DataGridView & lines 30 & ReadOnly; 
      Field MyStateID  		Type cell & hide;
	  Field MyStateDesc		Type cell & text "Descrizione" & width 250;

Last edited Oct 25, 2016 at 1:00 PM by ciaociao72, version 36