1

(3 replies, posted in Script)

How To Edit Script  Remove 

Save Password ☑

Stat Dialog connect MySQL

or
Save Password Visible := False ?

https://i.ibb.co/ZfRYc8x/D20250116-T144005.png

2

(3 replies, posted in General)

Try

var
  WinHttpReq  : Variant;
  url : String ;
begin
  WinHttpReq  := CreateOleObject('WinHttp.WinHttpRequest.5.1');
  url := 'https://checkupdate-xi3tiqz4rq-uc.a.run.app/?prg=sangkapp' ;
  WinHttpReq.open('GET',url,false);
  WinHttpReq.SetRequestHeader('Connection','keep-alive');
  WinHttpReq.SetRequestHeader('Content-Type', 'application/json');
  WinHttpReq.SetRequestHeader('ContentEncoding','UTF-8');
  WinHttpReq.send;
  Showmessage( 'Status = '+ #13#10 +IntToStr(WinHttpReq.Status) + #13#10 +'ResponseText ='+ #13#10 + WinHttpReq.ResponseText) ;
end;

Try

IF WinHttpReq.Status = 200 
Then 
Showmessage(WinHttpReq.ResponseText)
Else Showmessage('Error') ;
sparrow wrote:

Hi,
Something like this


procedure OnDblClick(Sender: TObject);
var
  i: integer;
  tli: TListItems;
begin
  tli := listview.items;
  for i:=0 to tli.count - 1 do
  begin
    if tli.item[i].selected then showmessage(tli.item[i].caption);
  end;
end;

begin
...
listview.OnDblClick := @OnDblClick;
end.

OK It Work Thank You sparrow

IF i Will Show Column2 , Column3
How To Edit Code ?

https://i.ibb.co/DG2K7wX/D20240723-T095045.png

Download
https://myvisualdatabase.com/forum/misc … download=1

How to Sort Order by Name value in JSonArray and add to Memo1


Example

[
    {
        "Name": "Cat",
        "Color": "White"
    },
    {
        "Name": "Ant",
        "Color": "Red"
    },
    {
        "Name": "Zebar",
        "Color": "Black"
    }
]

I will To result

Ant,Red
Cat,White
Zebar,Black






------------------------------------------------------------

Try Easy Code But  Result  Not Order By Name

Cat,White
Ant,Red
Zebar,Black

How To Edit Code ???

procedure MyProcedure();
var
JsonArray : TJsonArray  ;
i         : Integer     ;
JS_temp   : TJsonObject ;
js_name   : TJsonString ;
js_color  : TJsonString ;
begin
    JsonArray := TJsonArray.ParseJSONValue(
    '[
    {
        "Name": "Cat",
        "Color": "White"
    },
    {
        "Name": "Ant",
        "Color": "Red"
    },
    {
        "Name": "Zebar",
        "Color": "Black"
    }
    ]'
    );
    for i := 0 to JsonArray.Size -1 do
    begin
        js_temp := TJSONObject (TJSONObject(JsonArray.Get(i))) ;
        js_name := TJSONString(JS_temp.GetPairByName('balance').JsonValue);
        js_color := TJSONString(JS_temp.GetPairByName('color').JsonValue);
        Form1.Memo1.Lines.add(js_name.Value+','+js_color.Value)
    end;
end;

6

(4 replies, posted in Script)

jean.brezhonek wrote:

Oups I've forgotten the snippet
JB


Thank  JB Script It

procedure frmEmployee_OnClose (Sender: string; Action: string);
var     i,c: integer;
begin
    c := frmEmployee.ComponentCount-1;
    for i := 0 to c do
    begin
        if frmEmployee.Components[i] is TdbEdit then TdbEdit(frmEmployee.Components[i]).Clear;       //  Dans le cas d'un TEdit
        if frmEmployee.Components[i] is TdbMemo then TdbMemo(frmEmployee.Components[i]).Clear;       //  Dans le cas d'un TMemo
    end;
end;
JB

✓ Check IF TdbEdit >>> Clear Thank you JB

Um..... And IF
1. TdbEdit ✓
2. copy(Component_Name,5,Length(Component_Name)) MOD 2 = 0
How Do Edit Scipt ???

Form1.Edit1.Text
Form1.Edit2.Clear // Because (1. TdbEdit)+ (2. Component_Name MOD 2 = 0)
Form1.Edit3.Text
Form1.Edit4.Clear // Because (1. TdbEdit)+ (2. Component_Name MOD 2 = 0)

7

(4 replies, posted in Script)

I want to clear multiple edit boxes using the Loop method to reduce the number of lines in scripting.
Normally I write

Form1.Edit1.Clear ;
Form1.Edit2.Clear ;
Form1.Edit3.Clear ;
Form1.Edit4.Clear ;
Form1.Edit5.Clear ;
Form1.Edit6.Clear ;
Form1.Edit7.Clear ;
Form1.Edit8.Clear ;
Form1.Edit9.Clear ;
Form1.Edit10.Clear;

But if I want to write a Loop?

For i := 1 To 10 do
  begin
    Form1.Edit[i].Clear ; // How To Edit Script 
  end;

Help Me Please ?

8

(8 replies, posted in Script)

sparrow wrote:
prahousefamily wrote:
sparrow wrote:

Could you please attach the project or test project and the import file.


- option
1. Declare variables within procedures only.
2. Do not declare variables that are Public.


Unfortunately, I don’t yet see a solution in MVD with such requirements. Global variables are needed to save the state of variables in a procedure (loop), otherwise the process will start from the state of the variable that is defined in the procedure.
Of course, you can do as you did in the example with the Excel file name, remembering state variables in invisible Edit on the form. But this is a kind of analogue of a global variable.



IF Declare variables are Public.
Can Start/Stop/Continue ?

9

(8 replies, posted in Script)

sparrow wrote:

Could you please attach the project or test project and the import file.

I attach file project
Help me Please

- option
1. Declare variables within procedures only.
2. Do not declare variables that are Public.

https://i.ibb.co/1mQKL4p/D20240614-T085024.png


Project https://www.uupload.net/316

10

(8 replies, posted in Script)

sparrow wrote:

Hi,


Something like this



Can To Apply  Procedure Read Excel To TStringlist add value format CSV ?

procedure ReadExcelDataAndStoreInTStringList(const FileName: string; List: TStringList);
var
ExcelApp: Variant;
Workbook: Variant;
Sheet: Variant;
Range: Variant;
Row, Col: Integer;
max_row : Integer ;
max_col : Integer ;
s : String ;
begin
    
// How To Edito Code For Start / Stop /Continue Loop ???

try
        ExcelApp := CreateOleObject('Excel.Application');
        ExcelApp.Workbooks.Open(FileName);
        Workbook := ExcelApp.ActiveWorkbook;
        Sheet := Workbook.Sheets[1];
        Sheet.Activate ;
        Sheet.UsedRange.Select ;
        max_row := Sheet.UsedRange.Rows.Count ;
        max_col := Sheet.UsedRange.Columns.Count ;
        list.clear;
        for Row := 1 to max_row Do
        begin
            s := '' ;
            for Col := 1 to max_col Do
            begin
                Range := Sheet.Cells[Row,Col];
                IF col = 1
                Then s := s+Range.text
                Else s := s+'|'+Range.text  ;
                Application.ProcessMessages ;
            end;
            List.Add(s);
        end;
        finally
        Workbook.Close(False);
        ExcelApp.Quit;
    end;
end;

1. push button for start loop
2. push button again  for stop loop
3. push button again  for continue loop

How to Edit code ?

11

(8 replies, posted in Script)

I will
1. push button for start loop
2. push button again  for stop loop
3. push button again  for continue loop

How to Edit code ?

set i : Integer ;
begin
    i : 1;
    While i > 0 do
    begin
    Form1.Memo1.Lines.add(inttostr(i));
    i:=i+1;
    end;
end;
sparrow wrote:

MySQL 8.0 supports a new authentication based on improved, stronger SHA256-based password methods.

Unfortunately, MVD does not support new authentication, and FreeDB does not support legacy authentication.


How To Fix Error Or Custom Script In MVD ?

sql.freedb.tech mysql 8.0 online free service  and can connect  remote by client DBeaver,HeidiSQL

Link https://freedb.tech/

but MVD Connect  error

#80044 Client does not support authentication protocol requested by server; consider upgrading MySQL client.

How To Connect ?

MVD ERROR
https://i.ibb.co/hgYFFTT/D20240105-T091103.png






IF Use DBeaver OK
https://i.ibb.co/VYYWXR2/D20240105-T092454.png

sparrow wrote:

Hi,


Why are you using ExtractFileName(FileName).
You are extracting the filename without the path.
In this case, the program tries to find it in its directory, but it is not there.
You need to specify the full name (path + name).

And with quotation marks in the send request, be more careful.


I try Full path+name Result Error {"status":400,"message":"Invalid image."} How To Edit Script ?

         '----AAA'+#13#10+
         'Content-Disposition: form-data; name="message"'+#13#10+#13#10+
         #13#10+'['+FormatDateTime('yyyy-mm-dd hh:nn:zz', Now)+' : Test-MVD-API'+']'+#13#10+
         '----AAA'+#13#10+
         'Content-Disposition: form-data; name="imageFile"; filename="C:\Pic\pas.png"'#13#10 +
         'Content-Type: image/png'+#13#10+#13#10+
         #13#10+'----AAA--'+#13#10

hi sparrow
1. Try use Postman result  OK Send message and image Correct

{"status":200,"message":"ok"}

https://i.ibb.co/k1snVt9/D20230607-T094225.png

2. Try use MVD use WinHttp.WinHttpRequest.5.1 + multipart/form-data; boundary=--AAA + message OK Send message Correct

{"status":200,"message":"ok"}

https://i.ibb.co/HXmBJdX/D20230607-T094733.png
mvd code

var
WinHttpReq : Variant;
procedure Form1_Button1_OnClick (Sender: TObject; var Cancel: boolean);
var
url  : String ;
token : String ;
FileName : String;
begin
    FileName := 'C:\Pic\pas.png' ;
    token := 'xxxxxxxxxx' ;
    WinHttpReq.Open('POST','https://notify-api.line.me/api/notify', false);
    WinHttpReq.SetRequestHeader('Authorization','Bearer '+token) ;
    WinHttpReq.SetRequestHeader('Content-Type', 'multipart/form-data; boundary=--AAA');
    Try
        WinHttpReq.Send(
        '----AAA'+#13#10+
        'Content-Disposition: form-data; name="message"'+#13#10+#13#10+
        #13#10+'['+FormatDateTime('yyyy-mm-dd hh:nn:zz', Now)+' : Test-MVD-API'+']'+#13#10+
        #13#10+'----AAA--'+#13#10);
        Form1.Memo1.Lines.Add( WinHttpReq.Responsetext );
        Except
        Showmessage(ExceptionMessage) ;
    End;
end;
begin
    WinHttpReq := CreateOleObject('WinHttp.WinHttpRequest.5.1');
end.

3. Try use MVD use WinHttp.WinHttpRequest.5.1 + multipart/form-data; boundary=--AAA + message + image  = Error
Help me Please ?

{"status":400,"message":"Invalid image."}

mvd code

var
WinHttpReq : Variant;
procedure Form1_Button1_OnClick (Sender: TObject; var Cancel: boolean);
var
url  : String ;
token : String ;
FileName : String;
begin
    FileName := 'C:\Pic\pas.png' ;
    token := 'xxxxxxxxxx' ;
    WinHttpReq.Open('POST','https://notify-api.line.me/api/notify', false);
    WinHttpReq.SetRequestHeader('Authorization','Bearer '+token) ;
    WinHttpReq.SetRequestHeader('Content-Type', 'multipart/form-data; boundary=--AAA');
    Try
        WinHttpReq.Send(
        '----AAA'+#13#10+
        'Content-Disposition: form-data; name="message"'+#13#10+#13#10+
        #13#10+'['+FormatDateTime('yyyy-mm-dd hh:nn:zz', Now)+' : Test-MVD-API'+']'+#13#10+
        '----AAA'+#13#10+
        'Content-Disposition: form-data; name="imageFile"; filename="'+ ExtractFileName(FileName) +'"'#13#10 +
        'Content-Type: image/png'+#13#10+#13#10+
        #13#10+'----AAA--'+#13#10);
        Form1.Memo1.Lines.Add( WinHttpReq.Responsetext );
        Except
        Showmessage(ExceptionMessage) ;
    End;
end;
begin
    WinHttpReq := CreateOleObject('WinHttp.WinHttpRequest.5.1');
end.

In Postman test API post method Line Notify
text message and upload image
result

{"status":200,"message":"ok"}

https://i.ibb.co/425Hw9S/D20230602-T094551.png

Postman Code HTTP

POST /api/notify HTTP/1.1
Host: notify-api.line.me
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
Authorization: Bearer 123456789
Content-Length: 296

------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="message"

test
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="imageFile"; filename="/C:/Pic/D20230524T092936.png"
Content-Type: image/png

(data)
------WebKitFormBoundary7MA4YWxkTrZu0gW--

Postman Code curl

curl --location '[url]https://notify-api.line.me/api/notify[/url]' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Authorization: Bearer 123456789' \
--form 'message="test"' \
--form 'imageFile=@"/C:/Pic/D20230524T092936.png"'



IN MVD  I'm Try use method  "WinHttp.WinHttpRequest.5.1"  Post And Upload Image File
IF Sendy Message Only It "OK"
but
IF Send Message + Upload Image Result Error
How To Edit Script ? Help Me Please

MyScript In MVD

var
WinHttpReq : Variant;
procedure Form1_Button1_OnClick (Sender: TObject; var Cancel: boolean);
var
url : String;
imageFile : String ;
token : String ;
body : Tstringlist ;
begin
body := Tstringlist.create ;
    token := '123456789' ;
    imageFile := 'imageFile=@"/C:/Pic/D20230524T092936.png"';
    url := 'https://notify-api.line.me/api/notify' ;
    WinHttpReq.Open('POST',url, False);
    WinHttpReq.SetRequestHeader('ContentEncoding','UTF-8');
    WinHttpReq.SetRequestHeader('Content-Type','application/x-www-form-urlencoded') ;
    WinHttpReq.SetRequestHeader('Authorization','Bearer '+token) ;
    Try
        WinHttpReq.send('message="test"'+'\'+'imageFile=@"/C:/Pic/D20230524T092936.png"');
        ShowMessage(WinHttpReq.ResponseText);
        Except
        Showmessage(ExceptionMessage) ;
    End;
body.Free ;
end;
begin
    WinHttpReq := CreateOleObject('WinHttp.WinHttpRequest.5.1');
end.

In

17

(1 replies, posted in Script)

How  to Show list  scanner device and read jpg from scanner and show  all image & save in project MVD
----------
Note

  • in  mvd have Tprinter  but not have Scanner Or Fax
    windows 10 have "Windows Fax and Scan"  How Use command line in MVD ?



https://i.ibb.co/bF3vFtQ/unnamed0.jpg

In Project Use Function

Form1.TableGrid1.ExportToExcel(savefilepathname,False,True);

It Error

https://i.postimg.cc/W1MFFkdG/D20221228-T112149.png


How To Fix Error


PC Spec

Windows 10 Home 64 Bit
Ram 8 GB
SSD

19

(5 replies, posted in Script)

I Try Create Toolbar and Toolbutton By Array Of TToolbutton
----
Create ToolBar OK
Create TToolbutton OK
But Not Show Caption  In TToolbutton

How to Show Caption In Toolbutton ?

var
toolbar : Ttoolbar ;
toolbar_list : array of TToolbutton ;
i : Integer ;
begin
    toolbar := Ttoolbar.Create(Form1) ;
    toolbar.Parent := Form1.Panel1 ;
    toolbar.showcaptions := true;
    toolbar.Autosize := True ;
    toolbar_list := ['AAA','BBB','CCC'] ;
    For i := Length(toolbar_list) - 1 DownTo 0 DO
    Begin
        toolbar_list[i] := ttoolbutton.create(Form1) ;
        toolbar_list[i].parent   := toolbar;
        toolbar_list[i].Autosize := True ;
        toolbar_list[i].width    := 100 ;
        toolbar_list[i].caption  := toolbar_list[i].Name ;
    End;
end.

https://i.ibb.co/wZtnbZ3/image-2022-12-22-152109309.png

20

(2 replies, posted in Script)

IN MVD project i try write method Post,GET than standard function

WinHttpReq  : Variant;
WinHttpReq := CreateOleObject('WinHttp.WinHttpRequest.5.1');

Because in MVD standard function haven't this  or unable to improve further setting

In Windows 10 It OK  Not Error
But Windows 7 and Show Popup This

OLE error 80020009:send : Exception occurred
Source :: WinHttp.WinHttpRequest
Description :: An error in secure channel support

How To  Fix problem ???

https://i.postimg.cc/NfQtdTBX/D20221004-T114606.png

21

(2 replies, posted in Reports)

I try input string in memo and check AllowHTMLTags  = True
but  tag <P>

 <p>This is some text in a paragraph.</p> 

not support
how to Fix  ???

22

(1 replies, posted in Script)

MVD Compile SQLite  in Version

sqlite_version() = 3.8.3
sqlite_source_id() = 2014-02-03 14:04:11 6c643e45c274e755dc5a1a65673df79261c774be

How to Upgrade Engine SQlite in MVD To Current Version  Up To Date (Version 3.39.3 (2022-09-05) ) At Compile Project ?
Because  SQLite New Version Support New Function and More ...

23

(4 replies, posted in Script)

sparrow wrote:

Hi all,


In memory ) of the forgotten Regular Expression (TRegExp) is dedicated.
Code modified without agreement but simplified.


Thank You sparrow Best Example TRegExp

24

(12 replies, posted in Script)

Thank sparrow For Best Example Good Code By Use Tregexp

https://i.ibb.co/cLFFJ4y/D20220929-T065738.png

25

(12 replies, posted in Script)

Thank You Very Much pavlenko.vladimir.v For Link
I try script but error not have class or component in MVD
========================================

vovka3003 give script It Good but   result ➝ JsonString
example
"app_name": "Test"
Scritp By vovka3003 result = "Test"


I don't know what it's called. Name Or KEY OR Field Name ..... But I will input number index ➝ result ➝ xxx
example
"app_name": "Test"
input number 0
result = "app_name"
or Reverse  I will input String Field Name For Find Index ➝ result ➝ index number
example
"app_name": "Test"
input String  "app_name"
result = 0


Help me Please vovka3003 or pavlenko.vladimir.v ! Everybody
Thank You Again

https://i.postimg.cc/HLm9gMmQ/D20220825-T114652.png