RETURN TO INDEX

codiphone.com


BASIC LESSON 1 - GROUP I functions

MyLittleBase 2.0 API is divided into 7 groups of functions

1- Initialization functions
2-Fields functions
3-Rows functions
4-Navigation functions
5-Data management functions
6-File management functions
7-Utils

This lesson deals with the first group (Initialization functions)
and all what you can do with them.

This first group contains functions
Create (1.1)
Destroy (1.2)
Init (1.3)
Assign (1.3)
GetVersionNumber (1.4)
GetVersion (1.4)

Create and destroy are the constructor and destructor of the mlb2 object.
Use them to create a new instance of the object, and to free it at the end of your work.
DELPHI C++
To create a new instance of mlb2 object

first add mlb2 in the uses clause of your program:
uses forms, ..., mlb2;
then declare a new TMlb2 variable somewhere in your class or in your programs:
var myinstance: TMlb2;
then Create your instance:
myinstance := TMlb2.Create;

Now you can apply all mlb2 api to this instance, ex: myinstance.Init;

At the end of your work free the instance by applying the Free method calling the Destroy destructor:
myinstance.Free;

To use the mlb2 Drag and Drop component interface
Just drag and drop the mlbc component to your program's form, and apply mlb2 api to this instance;
To create a new instance of mlb2 object

first add the header file mlb2.h as include:

#include "mlb2.h";
then declare a new TMlb2 pointer somewhere in your class or in your programs:
TMlb2* myinstance;
then Create your instance:
myinstance = myinstance->Create();

Now you can apply all mlb2 api to this instance, ex: myinstance->Init();

At the end of your work free the instance by calling the Destroy destructor:
myinstance->Destroy();

 

Init and Assign initializes the table content itself.
Use Init to clear (totally erase content) any field and row of the table before adding new fields and new data.
Assign first clears the table as Init does then copies another table's content (all fields and rows).
DELPHI C++
To initialize a mlb2 table

call the Init method from a previously created instance:
myinstance.Init;

To Assign another table's data to a mlb2 table

call the Assign method from a previously created instance:
myinstance.Assign(otherinstance);
{other instance is another instance of TMlb2 object, all fields and rows are copied to myinstance object, myinstance contains now exactly the same fields and data than otherinstance }
To initialize a mlb2 table

call the Init method from a previously created instance:

myinstance->Init();

To Assign another table's data to a mlb2 table

call the Assign method from a previously created instance:
myinstance->Assign(otherinstance);


GetVersionNumber and GetVersion methods are used to get the current version number of the mylittlebase library you are using.
For sample version number of MyLittleBase 2.0 revision 0 is 200 (allways integer).
DELPHI C++
To get the version number of mlb2 object
call the GetVersionNumber API:
Caption := IntToStr(myinstance.GetVersionNumber);

To get the version string of mlb2 object

call the GetVersion API:
Caption := myinstance.GetVersion;
To get the version number of mlb2 object
call the GetVersionNumber API:
printf("%d", myinstance->GetVersionNumber());

To get the version string of mlb2 object

call the GetVersion API:
printf("%s", myinstance->GetVersion());

 

EXERCISE 1- Use group I functions to Initialize a new mlb2 object and to print the library's version number.
DELPHI C++
unit Unit1;

interface

uses
SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls, Forms, Dialogs, mlb2;

type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);

procedure FormDestroy(Sender: TObject);
private

        mlb1: TMlb2;
public
end;

var
Form1: TForm1;
mlb: TMlb2;


implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
begin

    mlb1 := TMlb2.Create;
    mlb := TMlb2.Create;

    mlb1.Assign(mlb); {copies mlb fields and rows to mlb1}
    mlb.Init;
    Caption :=IntToStr(mlb.GetVersionNumber);
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin

    mlb1.Free;
    mlb.Free;
end;

end.

#include <stdio.h>;
#include "mlb2.h";

int main(int argc, char* argv[]) {
    TMlb2* mlb = mlb->Create();
     printf("%d", mlb->GetVersionNumber());
     mlb->Destroy();
}
GROUP FONCTION 2 >>
ANIROM Multimedia
- www.anirom.com