76

(1 replies, posted in Script)

reference From 

http://www.schoolfreeware.com/Free_Pascal_Lazarus_App_GUI_Tutorial_12.html

Free Pascal Lazarus App Tutorial 12 - System Timer Bouncing Ball Animation - Shapes
A shape is added to the form. The shape is made into a circle, resized and colored red with the brush. A timer is added to allow the shape to move around the form. When the shape hits the side of the form the ball will bounce of the form’s side.




I try code to MVD and change Tshape To Panel

Look Little Funny Time

Screen Short
https://image.ibb.co/cggntV/2018-11-08-004.png

Open Code

var
Timer: TTimer;
procedure Form1_OnShow (Sender: string; Action: string);
begin
    Timer := TTimer.Create (nil);
    Timer.OnTimer := @OnTimer;
    Timer.Interval := 10;
    Timer.Enabled := True;
end;
procedure OnTimer;
var
G_Right: Boolean;
G_Up: Boolean;
R_Right: Boolean;
R_Up: Boolean;
Y_Right: Boolean;
Y_Up: Boolean;
begin
    if G_Up = True then
    Form1.Panel1.Top := Form1.Panel1.Top - 2
    else
    Form1.Panel1.Top := Form1.Panel1.Top + 2;
    if G_Right = True then
    Form1.Panel1.Left := Form1.Panel1.Left + 2
    else
    Form1.Panel1.Left := Form1.Panel1.Left - 2;
    if Form1.Panel1.Top <= 0 then
    G_Up := False;
    if Form1.Panel1.Top + Form1.Panel1.Height >= Form1.Height then
    G_Up := True;
    if Form1.Panel1.Left <= 0 then
    G_Right := True;
    if Form1.Panel1.Left + Form1.Panel1.Width >= Form1.Width then
    G_Right := False;
    if R_Up = True then
    Form1.Panel2.Top := Form1.Panel2.Top - 4
    else
    Form1.Panel2.Top := Form1.Panel2.Top + 4;
    if R_Right = True then
    Form1.Panel2.Left := Form1.Panel2.Left + 4
    else
    Form1.Panel2.Left := Form1.Panel2.Left - 4;
    if Form1.Panel2.Top <= 0 then
    R_Up := False;
    if Form1.Panel2.Top + Form1.Panel2.Height >= Form1.Height then
    R_Up := True;
    if Form1.Panel2.Left <= 0 then
    R_Right := True;
    if Form1.Panel2.Left + Form1.Panel2.Width >= Form1.Width then
    R_Right := False;
    if Y_Up = True then
    Form1.Panel3.Top := Form1.Panel3.Top -3
    else
    Form1.Panel3.Top := Form1.Panel3.Top +3;
    if Y_Right = True then
    Form1.Panel3.Left := Form1.Panel3.Left +3
    else
    Form1.Panel3.Left := Form1.Panel3.Left -3;
    if Form1.Panel3.Top <= 0 then
    Y_Up := False;
    if Form1.Panel3.Top + Form1.Panel3.Height >= Form1.Height then
    Y_Up := True;
    if Form1.Panel3.Left <= 0 then
    Y_Right := True;
    if Form1.Panel3.Left + Form1.Panel3.Width >= Form1.Width then
    Y_Right := False;
end;
procedure Form1_OnClose (Sender: string; Action: string);
begin
    Timer.Free;
end;
begin
end.

77

(6 replies, posted in Script)

I try Example in http://wiki.freepascal.org/TComboBox
But Error
I will to display like example
http://wiki.freepascal.org/images/7/70/ComboBoxBsp2.png

It hard code ! Who is can edit .... help me please again !

78

(6 replies, posted in Script)

It can show multiple column BUT Can Not Show  Image !
Help Me Please again!

79

(6 replies, posted in Script)

I try more code but error for insert  image or column  with combobox like  picture below

Help Me Please !

http://www.pp4s.co.uk/static/pp4s/images/forms/image_list.png

http://www.rosinsky.cz/design/combobox1.png

80

(20 replies, posted in General)

Wow It Beautiful beautiful component It good teach my student  ...

Have a little question
1 Can you add Symbol Or Equation in Richedit?
2 If you save in Richedit format, the text style is highlighted. Insert color if you want to display Richedit only or can use Memo instead?

Compile MVD 4.6 +++
Knowledge In This Example
- button can change caption or icon from value database
- can apply save setting insert to database and load value quick time program open
Happy Everybody MVD!

Screen Shot
https://image.ibb.co/hrdL8V/2018-11-06-001.png

Open Code

var
listview : Tlistview ;
ImageList: TImageList;
i : integer ;
sl: TStringList;
ci : integer ;
procedure Form1_TableGrid1_OnChange (Sender: TObject);
var
ti : integer ;
begin
    For ti := 0 to Form1.controlCount -1 do
    Begin
        IF (Form1.controls[ti] is TButton) then
        Begin
            TButton(Form1.Controls[ti]).caption :=
            SQLExecute('SELECT caption from button where ci = '+IntToStr(ti));
            TButton(Form1.Controls[ti]).images := ImageList ;
            TButton(Form1.Controls[ti]).imageindex :=
            SQLExecute('SELECT imageindex from button where ci = '+IntToStr(ti));
        End;        
    End;
end;
begin
    ImageList:=TImageList.Create(Form1);
    ImageList.Masked:=false;
    ImageList.ColorDepth:=cd32bit;
    ImageList.Width := 16;
    ImageList.Height := 16;
    sl := TStringList.Create;
    sl.Text := GetFilesList(ExtractFilePath(Application.ExeName)+'icon','*.png');
    For  i := 0 To sl.count-1 Do
    Begin
        ImageList.AddPng(sl[i]);
    end ;
    listview := Tlistview.Create(Form1);
    listview.Parent := Form1.Panel1;
    listview.Align := alClient;
    listview.StateImages := ImageList;
    listview.smallimages := ImageList;
    listview.Largeimages := ImageList;
    listview.GridLines  := True;
    listview.viewStyle := vsreport ;
    listview.Columns.add();
    listview.Columns.add();
    listview.Columns[0].caption := 'Icon : Name' ;
    listview.Columns[1].caption := 'Imageindex' ;
    listview.Columns[0].AutoSize := True ;
    listview.Columns[1].AutoSize := True ;
    For  i := 0 To sl.count-1 Do
    begin
        with ListView.Items.Add do
        begin
            ImageIndex := i;
            Caption  := ' : '+replacestr(sl[i],ExtractFilePath(Application.ExeName)+'icon\','');
            SubItems.Add(IntToStr(i));
        end;
    end;
    For ci := 0 to Form1.controlCount -1 do
    if (Form1.controls[ci] is TButton) then
    begin
        SQLExecute('INSERT INTO button(name,caption,imageindex,ci) values ('+
        '"'+TButton(Form1.Controls[ci]).name+'",'+
        '"'+TButton(Form1.Controls[ci]).caption+'",'+
        '"'+IntToStr(TButton(Form1.Controls[ci]).imageindex)+'",'+
        '"'+IntToStr(ci)+'" );');
    End;
end.

Knowledge In This Example
- MySQl SQL Syntax,
    "Show tables"
    "Show Create Table xxx"
- Tdaset : use loop auto generate ddl in table result
    Concat("Show tables","Show Create Table xxx")
- Tprogressbar
    show status countdown all process
- Event Script Combobox
    select database name for result

Happy Everybody MVD!

Screen Shot
https://image.ibb.co/iYpGnf/2018-11-01-004.png
Open Code

var
progressbar : Tprogressbar ;
procedure Form1_OnShow (Sender: TObject; Action: string);
Var
Q : TDataSet ;
begin
    SQLQuery('Show Databases ',Q);
    Form1.Combobox1.Clear;
    while not Q.Eof do begin
        Form1.Combobox1.Items.Add(Q.Fields.Fields[0].AsString);
        Q.Next;
    end;
    Q.Close;
end;
procedure Form1_ComboBox1_OnChange (Sender: TObject);
begin
    Form1.TableGrid1.dbSQL :=
    ' USE '+Form1.ComboBox1.Text +' ;' + #13#10 +
    ' SELECT TABLE_NAME, "DDL" FROM information_schema.TABLES ' + #13#10 +
    ' WHERE TABLE_SCHEMA = "'+Form1.ComboBox1.Text +'" ORDER BY TABLE_NAME ;';
    Form1.TableGrid1.dbSQLExecute ;
    Form1.Label3.Caption := 'Gen Table List 0 From '+ IntToStr(Form1.TableGrid1.RowCount) ;
    Form1.Label4.Caption := 'Progress '+'0.00 %' ;
end;
procedure Form1_Button1_OnClick (Sender: TObject; var Cancel: boolean);
var
i : Integer ;
result : Tdataset;
begin
    For i := 0 To Form1.TableGrid1.RowCount -1 Do
    Begin
        SQLQuery('Show Create Table '+Form1.TableGrid1.Cells[0,i], result);
        Form1.TableGrid1.Cells[1,i] := result.Fields[1].AsString;// ddl.Text;
        Form1.Label3.Caption := 'Gen Table List '+inttostr(i+1)+' From '+ IntToStr(Form1.TableGrid1.RowCount) ;
        Form1.Label4.Caption := 'Progress '+FormatFloat('0.00',(i+1)/(Form1.TableGrid1.RowCount)*100)+' %' ;
        progressbar.position :=  StrToInt(FormatFloat('0',(i+1)/(Form1.TableGrid1.RowCount)*100)) ;
        Application.ProcessMessages;
        result.Free;
    End;
    Form1.TableGrid1.BestFitColumns(bfboth);
    ShowMessage('OK!');
end;
begin
    progressbar := Tprogressbar.Create(Form1) ;
    progressbar.Parent := Form1.Panel1 ;
    progressbar.Align  := AlClient;
    progressbar.Min := 0;
    progressbar.max := 100;
    progressbar.position := 0 ;
end.

83

(2 replies, posted in Script)

Thank You Dmitry. It Work ...
Easy Code  And View Use

84

(2 replies, posted in Script)

I try create  Example  MySQL "Show Create Table mysql.xxx"
And generate DDL All Table  in database insert column ddl
when copy row and paste in NOTEPAD IT OK Show Full Content
But TableGrid Not display same like NOTEPAD
How To Show  ?

Open Code Fix 201810-18

procedure Form1_Button1_OnClick (Sender: TObject; var Cancel: boolean);
var
i : Integer ;
result : Tdataset;
ddl : Tstringlist;
begin
    Form1.TableGrid1.dbSQL :=
    ' USE mysql ;' + #13#10 +
    ' SELECT TABLE_NAME,NULL AS DDL  FROM information_schema.TABLES ' + #13#10 +
    ' WHERE TABLE_SCHEMA = ''mysql'' ORDER BY TABLE_NAME ;';
    Form1.TableGrid1.dbSQLExecute ;
    ddl := Tstringlist.Create ;
    For i := 0 To Form1.TableGrid1.RowCount -1 Do
    Begin
        Begin
            SQLQuery('Show Create Table '+Form1.TableGrid1.Cells[0,i] ,result);
            ddl.Add(result.Fields[1].AsString);
            ddl.Commatext;
            Form1.TableGrid1.Cells[1,i] := ddl.Text;
        End;
        ddl.clear;
        result.Free;
    End;
    Form1.TableGrid1.BestFitColumns(bfboth);
    Form1.TableGrid1.BestFitRow(1) ;
end;
begin
end.

https://image.ibb.co/eJa7bL/2018-10-17-001.png

85

(1 replies, posted in SQL queries)

Help Me Please !

How To Select "Show DDL All table"  : MySQL ???

I Try write It Ok but show null in DDL_TABLE field

SELECT
information_schema.TABLES.TABLE_NAME,
information_schema.TABLES.TABLE_ROWS,
NUll AS DDL_TABLE
FROM
    information_schema.TABLES,
WHERE
    information_schema.TABLES.TABLE_SCHEMA = (DATABASE());

When itry add ddl script "Show Create Table"  It Error

SELECT
information_schema.TABLES.TABLE_NAME,
information_schema.TABLES.TABLE_ROWS,
(SHOW CREATE TABLE information_schema.TABLES.TABLE_NAME) AS DDL_TABLE
FROM
    information_schema.TABLES,
WHERE
    information_schema.TABLES.TABLE_SCHEMA = (DATABASE());

Help Me Please !


https://image.ibb.co/kCF8nU/2018_09_26_001.png

86

(6 replies, posted in Script)

OK ! Get function TZip ...
https://image.ibb.co/khK9P9/2018_09_25_001.png

This is a bug because 4.7 beta Dropbox has 2 links.

87

(6 replies, posted in Script)

Dimitry Why Error ???

https://image.ibb.co/di35CU/2018_09_24_023.png

88

(1 replies, posted in Reports)

Please attach project or screen shot for help
Or Download Example Report Scipt

Example Report Script

procedure MasterData1OnBeforePrint(Sender: TfrxComponent);
begin
IF Copy(<Report."id">,Length(<Report."id">),1) = '1'   
Then Memo6.Font.Color := clred
Else If Copy(<Report."id">,Length(<Report."id">),1) = '2'  
Then Memo6.Font.Color := clgreen
Else If Copy(<Report."id">,Length(<Report."id">),1) = '3'  
Then Memo6.Font.Color := clgray      
Else If Copy(<Report."id">,Length(<Report."id">),1) = '4'  
Then Memo6.Font.Color := clblue
Else If Copy(<Report."id">,Length(<Report."id">),1) = '5'  
Then Memo6.Font.Color := clyellow
Else If Copy(<Report."id">,Length(<Report."id">),1) = '6'  
Then Memo6.Font.Color := clmaroon
Else If Copy(<Report."id">,Length(<Report."id">),1) = '7'  
Then Memo6.Font.Color := clnavy
Else If Copy(<Report."id">,Length(<Report."id">),1) = '8'  
Then Memo6.Font.Color := clolive
Else If Copy(<Report."id">,Length(<Report."id">),1) = '9'  
Then Memo6.Font.Color := cllime          
Else Memo6.Font.Color := clblack ;                              
  
end;

begin

89

(4 replies, posted in General)

Hi madbit71
try Example Download

windows 10 has default right click
send to >>> compressed file(ziped) folder
Or
Extract All
i will MVD have this function pure not use third party or External program

Please !

I will little help MVD Community  create multiple tdataset in report design by use value string in Tmemo custom syntax

Syntax
<dataset name"xxx">sql</dataset>

Example Image
https://image.ibb.co/kvBmSz/2018_09_06_001.png

Example Image With Design & Preview
https://image.ibb.co/cX6s0K/2018_09_06_003.png
https://image.ibb.co/kd1QLK/2018_09_06_004.png

Open Code

//Fix 2018-09-06 Script Example Report Flag
            
procedure Form1_Button3_OnClick (Sender: TObject; var Cancel: boolean);
var         
frxDBDatasets : array[0..999] OF TfrxDBDataset;
dts : array[0..999] OF Tdataset;
i : integer ;
dtssql : string;
dtsname : String;
begin
    Form1.frxReport.Clear;
    Form1.frxReport.DataSets.Clear;
    For i := 0 To Form1.ComboBox1.Items.Count - 1 Do
    begin
        //test show message
        dtsname := (
        Copy(
        Form1.ComboBox1.Items[i],
        Pos('<dataset name"',Form1.ComboBox1.Items[i])+14,
        Pos('">',Form1.ComboBox1.Items[i])-(Pos('<dataset name"',Form1.ComboBox1.Items[i])+14),
        )
        );
        Showmessage(dtsname);
        dtssql :=
        Copy(
        Form1.ComboBox1.Items[i],
        (Pos('">',Form1.ComboBox1.Items[i])+2),
        Pos('</dataset>',Form1.ComboBox1.Items[i]) - (Pos('">',Form1.ComboBox1.Items[i])+2)
        ) ;
        SQLQuery(dtssql, dts[i]);
        frxDBDatasets[i] := TfrxDBDataset.Create(Form1);
        frxDBDatasets[i].UserName        := dtsname;
        frxDBDatasets[i].CloseDataSource := True;
        frxDBDatasets[i].OpenDataSource  := True;
        frxDBDatasets[i].DataSet         := dts[i];
        Form1.frxReport.DataSets.Add(frxDBDatasets[i]);
    end;
    For i := 0 To Form1.ComboBox1.Items.Count - 1 Do
    frxDBDatasets[i].DataSet.Close ;

    Form1.frxReport.LoadFromFile(ExtractFilePath(Application.ExeName)+'Report\test.fr3');
    Form1.frxReport.ShowReport;

    For i := 0 To Form1.ComboBox1.Items.Count - 1 Do
    frxDBDatasets[i].DataSet.Free ;

end;

procedure Form1_Button2_OnClick (Sender: TObject; var Cancel: boolean);
var
st_temp : String;
vt_name : tstringlist;
result_sql : String;
get_x,get_y : Integer;
para_x,para_y : Integer;
paraname : string;
dts : array[0..999] of ttoolbar;
dtsi: integer;
begin
//start
    st_temp := Form1.Memo1.Text ;
    result_sql := Form1.Memo1.Text;
    vt_name := tstringlist.Create ;
    vt_name.Clear ;
    Form1.ComboBox1.Items.clear ;
    Repeat
    begin
        get_x    := Pos('<dataset name"',st_temp);
        st_temp  := Copy(st_temp,get_x,Length(st_temp));
        get_y    := Pos('</dataset>',st_temp) ;
        paraname := Copy(st_temp,1,get_y+9);
        IF Pos(paraname,vt_name.Text) <= 0 Then
        vt_name.Add(paraname) ;
        Form1.ComboBox1.Items.add(paraname);
        st_temp  := copy(st_temp,get_y+10,Length(st_temp) );
    end;
    until Pos('<dataset name"',st_temp) <= 0;
end;

procedure Form1_Button1_OnClick (Sender: TObject; var Cancel: boolean);
var
frxDBDatasets : array[0..999] OF TfrxDBDataset;
dts : array[0..999] OF Tdataset;
i : integer ;
dtssql : string;
dtsname : String;
begin
    Form1.frxReport.Clear;
    Form1.frxReport.DataSets.Clear;
    For i := 0 To Form1.ComboBox1.Items.Count - 1 Do
    begin
        //test show message
        dtsname := (
        Copy(
        Form1.ComboBox1.Items[i],
        Pos('<dataset name"',Form1.ComboBox1.Items[i])+14,
        Pos('">',Form1.ComboBox1.Items[i])-(Pos('<dataset name"',Form1.ComboBox1.Items[i])+14),
        )
        );
        Showmessage(dtsname);
        dtssql :=
        Copy(
        Form1.ComboBox1.Items[i],
        (Pos('">',Form1.ComboBox1.Items[i])+2),
        Pos('</dataset>',Form1.ComboBox1.Items[i]) - (Pos('">',Form1.ComboBox1.Items[i])+2)
        ) ;
        SQLQuery(dtssql, dts[i]);
        frxDBDatasets[i] := TfrxDBDataset.Create(Form1);
        frxDBDatasets[i].UserName        := dtsname;
        frxDBDatasets[i].CloseDataSource := True;
        frxDBDatasets[i].OpenDataSource  := True;
        frxDBDatasets[i].DataSet         := dts[i];
        Form1.frxReport.DataSets.Add(frxDBDatasets[i]);
    end;                                                    
    Form1.frxReport.LoadFromFile(ExtractFilePath(Application.ExeName)+'Report\test.fr3');
    Form1.frxReport.DesignReport;
    For i := 0 To Form1.ComboBox1.Items.Count - 1 Do
    frxDBDatasets[i].free ;
end;
procedure Form1_ComboBox1_OnChange (Sender: TObject);
begin
    Form1.Memo2.Text :=
    Copy(
    Form1.ComboBox1.Text,
    Pos('<dataset name"',Form1.ComboBox1.Text)+14,
    Pos('">',Form1.ComboBox1.Text)-(Pos('<dataset name"',Form1.ComboBox1.Text)+14),
    );
    Form1.Memo3.Text :=
    Copy(
    Form1.ComboBox1.Text,
    (Pos('">',Form1.ComboBox1.Text)+2),
    Pos('</dataset>',Form1.ComboBox1.Text) - (Pos('">',Form1.ComboBox1.Text)+2)
    );
    Form1.TableGrid1.ClearRows;
    Form1.TableGrid1.dbSQL := Form1.Memo3.Text;
    Form1.TableGrid1.dbSQLExecute;
end;
procedure Form1_OnShow (Sender: TObject; Action: string);
var
st_temp : String;
vt_name : tstringlist;
result_sql : String;
get_x,get_y : Integer;
para_x,para_y : Integer;
paraname : string;
dts : array[0..999] of ttoolbar;
dtsi: integer;
begin
    Form1.Memo1.Lines.LoadFromfile(ExtractFilePath(Application.exename)+'\sql.txt');
    //start
    st_temp := Form1.Memo1.Text ;
    result_sql := Form1.Memo1.Text;
    vt_name := tstringlist.Create ;
    vt_name.Clear ;
    Repeat
    begin
        get_x    := Pos('<dataset name"',st_temp);
        st_temp  := Copy(st_temp,get_x,Length(st_temp));
        get_y    := Pos('</dataset>',st_temp) ;
        paraname := Copy(st_temp,1,get_y+9);
        IF Pos(paraname,vt_name.Text) <= 0 Then
        vt_name.Add(paraname) ;
        Form1.ComboBox1.Items.add(paraname);
        st_temp  := copy(st_temp,get_y+10,Length(st_temp) );
    end;
    until Pos('<dataset name"',st_temp) <= 0;
end;
begin
end.

92

(4 replies, posted in Script)

Fix 2018-08-02
---- Check  variable  before execute 

IF vt_name[para_x] <> '' Then

Full Fix Code

//Advance Like Navicat
procedure Form1_Button2_OnClick (Sender: TObject; var Cancel: boolean);
var
st_temp : String;
vt_name : tstringlist;
result_sql : String;
get_x,get_y : Integer;
para_x,para_y : Integer;
paraname : string;
begin
    st_temp := Form1.Memo3.Text ;
    result_sql := Form1.Memo3.Text;
    vt_name := tstringlist.Create ;
    vt_name.Clear ;
    Repeat
    begin
        get_x    := Pos('[$',st_temp);
        st_temp  := Copy(st_temp,get_x,Length(st_temp));
        get_y    := Pos(']',st_temp) ;
        paraname := Copy(st_temp,1,get_y);
        IF Pos(paraname,vt_name.Text) <= 0 Then
        vt_name.Add(paraname) ;
        st_temp  := copy(st_temp,get_y+1,Length(st_temp) );
    end;
    until Pos('[$',st_temp) <= 0;
    For para_x := 0 To  vt_name.Count -1 Do
    Begin
IF vt_name[para_x] <> '' Then
        result_sql :=
        ReplaceStr(result_sql ,vt_name[para_x],
        '"'+
        InputBox('Input Parameter',ReplaceStr(ReplaceStr(vt_name[para_x],'[$',''),']','') ,'')+
        '"'
        );
    end;
    Form1.TableGrid1.dbSQL := result_sql;
    Form1.TableGrid1.dbSQLExecute ;
    vt_name.Clear ;
End;
// Core Script Search Parameter And Distinct Insert In Stringlist
procedure Form1_Button1_OnClick (Sender: TObject; var Cancel: boolean);
var
st_temp : String;
get_x,get_y : Integer;
paraname : string;
begin
    Form1.Memo2.Clear;
    st_temp  := Form1.Memo1.Text ;
    Repeat
    begin
        get_x    := Pos('[$',st_temp);
        st_temp  := Copy(st_temp,get_x,Length(st_temp));
        get_y    := Pos(']',st_temp) ;
        paraname := Copy(st_temp,1,get_y);
        IF Pos(paraname,Form1.Memo2.Text) <= 0 Then
        Form1.Memo2.Lines.Add(paraname) ;
        st_temp  := copy(st_temp,get_y+1,Length(st_temp) );
    end;
    until Pos('[$',st_temp) <= 0;
End;
procedure Form1_OnShow (Sender: TObject; Action: string);
begin
    Form1.Memo1.lines.loadFromFile('Lorem.txt');
    Form1.Memo3.Text :=
    'SELECT' + #13#10 +
    '    CAST ([$paraname1] AS text) AS paraname1,' + #13#10 +
    '    CAST ([$paraname2] AS text) AS paraname2,' + #13#10 +
    '    CAST ([$paraname1] AS text) AS paraname3_like_paraname1';
end;
begin
end.   

93

(0 replies, posted in General)

requirement 4.5 beta add component  TAdvMemo  like  tab script  in MVD
For
- Show line number
- Show count position character
look easy when edit note or memo
Help please !

https://image.ibb.co/jbdjE8/2018_07_13_001.png

94

(5 replies, posted in General)

- added function to resize graphic files

Decrease file size in  capacity disk ?
Or
Change Size Width ,Height Image ?

I Will MVD Community Happy In This Script Help Insert parameter  in statement 
Use applied InputBox Function in MVD Insert in  statement query string like feature Navicat Query Parameters


Navicat Feature

Query Parameters

Query Builder and Query Editor both support using of parameters inside the query text. You can set query parameters to add variable values to a query each time you run it. The parameter should appear as an identifier with $ at its beginning, quote with [ ], e.g. [$any_name].

Execute the query and the Input Parameter Dialog is provided for you to enter the desired data you wish to search.

Navicat Screen
https://i.imgur.com/WwWrDoI.png


MVD Screen Like Navicat
https://i.imgur.com/YhGD25O.png


Open Code Script

//Advance Like Navicat
procedure Form1_Button2_OnClick (Sender: TObject; var Cancel: boolean);
var
st_temp : String;
vt_name : tstringlist;
result_sql : String;
get_x,get_y : Integer;
para_x,para_y : Integer;
paraname : string;
begin
    st_temp := Form1.Memo3.Text ;
    result_sql := Form1.Memo3.Text;
    vt_name := tstringlist.Create ;
    vt_name.Clear ;
    Repeat
    begin
        get_x    := Pos('[$',st_temp);
        st_temp  := Copy(st_temp,get_x,Length(st_temp));
        get_y    := Pos(']',st_temp) ;
        paraname := Copy(st_temp,1,get_y);
        IF Pos(paraname,vt_name.Text) <= 0 Then
        vt_name.Add(paraname) ;
        st_temp  := copy(st_temp,get_y+1,Length(st_temp) );
    end;
    until Pos('[$',st_temp) <= 0;
    For para_x := 0 To  vt_name.Count -1 Do
    Begin
        result_sql :=
        ReplaceStr(result_sql ,vt_name[para_x],
        '"'+
        InputBox('Input Parameter',ReplaceStr(ReplaceStr(vt_name[para_x],'[$',''),']','') ,'')+
        '"'
        );
    end;
    Form1.TableGrid1.dbSQL := result_sql;
    Form1.TableGrid1.dbSQLExecute ;
    vt_name.Clear ;
End;
// Core Script Search Parameter And Distinct Insert In Stringlist
procedure Form1_Button1_OnClick (Sender: TObject; var Cancel: boolean);
var
st_temp : String;
get_x,get_y : Integer;
paraname : string;
begin
    Form1.Memo2.Clear;
    st_temp  := Form1.Memo1.Text ;
    Repeat
    begin
        get_x    := Pos('[$',st_temp);
        st_temp  := Copy(st_temp,get_x,Length(st_temp));
        get_y    := Pos(']',st_temp) ;
        paraname := Copy(st_temp,1,get_y);
        IF Pos(paraname,Form1.Memo2.Text) <= 0 Then
        Form1.Memo2.Lines.Add(paraname) ;
        st_temp  := copy(st_temp,get_y+1,Length(st_temp) );
    end;
    until Pos('[$',st_temp) <= 0;
End;
procedure Form1_OnShow (Sender: TObject; Action: string);
begin
    Form1.Memo1.lines.loadFromFile('Lorem.txt');
    Form1.Memo3.Text :=
    'SELECT' + #13#10 +
    '    CAST ([$paraname1] AS text) AS paraname1,' + #13#10 +
    '    CAST ([$paraname2] AS text) AS paraname2,' + #13#10 +
    '    CAST ([$paraname1] AS text) AS paraname3_like_paraname1';
end;
begin
end.             

96

(1 replies, posted in Script)

How To Replace Text In '['+Alltext+']'
Example Original text

[Lorem Ipsum] is [simply dummy] text of the printing [and] typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

For Result

XXX is XXX text of the printing XXX typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

How To use function Or Edit code ???

97

(1 replies, posted in General)

Hi derek Thank You Example Sorted Order In Treeview
It Code Easy Understand use SQL fix It..
Um... i have  little If i will to re order NODE by  Name not ID
How to edit script ???
From
http://myvisualdatabase.com/forum/viewtopic.php?id=4257

98

(1 replies, posted in General)

How to edit script for show  combobox like textbox same inputbox

function InputBox(,,) 

and  setting is var public function for use in MVD

How can edit ???

function InputComboBox('Dialog Caption','Dialog Lable','ComboboxItemsList','SelectComboboxItem') 

Like Same Picture
http://www.swissdelphicenter.ch/screenshots/tip2422.png

reference from http://www.swissdelphicenter.ch/en/showcode.php?id=2422

99

(1 replies, posted in Script)

how to set Tstatus and add width panel auto width

StatusBar.Panels.Items[0].Width := Textwidth + 16 

help me please !

100

(3 replies, posted in General)

Thank You manixs2013 & carlo_dj

Effect By
- Form Set  KeyPreview := True  >> manixs2013
- Change Script Follow >> carlo_dj

procedure Form1_OnKeyDown (Sender: TObject; var Key: Word; Shift, Alt, Ctrl: boolean);
begin
 if Key=13 then Form1.SetFocusNextControl;
end;
begin
Form1.KeyPreview := True ;
end.