1 (edited by prahousefamily 2024-06-13 04:28:37)

Topic: How to Edit Script For Stop and Continue Loop ?

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;
My Visual Database : I Love You
Easy For Beginner Student For Me

Re: How to Edit Script For Stop and Continue Loop ?

Hi,


Something like this

Post's attachments

Attachment icon tst loop.zip 3.87 kb, 29 downloads since 2024-06-13 

3 (edited by prahousefamily 2024-06-13 07:18:10)

Re: How to Edit Script For Stop and Continue Loop ?

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 ?

My Visual Database : I Love You
Easy For Beginner Student For Me

Re: How to Edit Script For Stop and Continue Loop ?

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

5 (edited by sparrow 2024-06-13 11:02:08)

Re: How to Edit Script For Stop and Continue Loop ?

Something like this

Post's attachments

Attachment icon tst loop-row-col.zip 4.96 kb, 36 downloads since 2024-06-13 

6 (edited by prahousefamily 2024-06-14 02:07:34)

Re: How to Edit Script For Stop and Continue Loop ?

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

Post's attachments

Attachment icon HowTo.zip 20.51 kb, 27 downloads since 2024-06-14 

My Visual Database : I Love You
Easy For Beginner Student For Me

Re: How to Edit Script For Stop and Continue Loop ?

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.

Re: How to Edit Script For Stop and Continue Loop ?

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 ?

My Visual Database : I Love You
Easy For Beginner Student For Me

Re: How to Edit Script For Stop and Continue Loop ?

Something like this

Post's attachments

Attachment icon HowTo-m.zip 375.67 kb, 34 downloads since 2024-06-14