|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
Breaking processesHow can I stop the execution of a loop which includes shell command for
copying files? Example: PUBLIC SUB FCopy() DIM i AS Integer DIM filepaths AS String[] ........................' the array filepaths is filled with contents FOR i=0 To filepaths.Count-1 SHELL "cp -f " & filepaths[i] & " /home/destination" NEXT END I'd like to add a Cancel button which would break the loop.Thanks! ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Gambas-user mailing list Gambas-user@... https://lists.sourceforge.net/lists/listinfo/gambas-user |
|
|
Re: Breaking processes Hey M,
to stop the execution of a for loop all you have to do is check for a condition then use break for example PUBLIC SUB FCopy() DIM i AS Integer Dim stopLoop as Boolean DIM filepaths AS String[] ........................' the array filepaths is filled with contents FOR i=0 To filepaths.Count-1 if stopLoop = False THEN SHELL "cp -f " & filepaths[i] & " /home/destination" Else BREAK ENDIF NEXT I hope this helps Regards, Dimitris On Wed, Nov 4, 2009 at 3:41 AM, M. Cs. <mohareve@...> wrote: > How can I stop the execution of a loop which includes shell command for > copying files? > > Example: > PUBLIC SUB FCopy() > DIM i AS Integer > DIM filepaths AS String[] > ........................' the array filepaths is filled with contents > FOR i=0 To filepaths.Count-1 > SHELL "cp -f " & filepaths[i] & " /home/destination" > NEXT > > END > > I'd like to add a Cancel button which would break the loop.Thanks! > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day > trial. Simplify your report design, integration and deployment - and focus > on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > _______________________________________________ > Gambas-user mailing list > Gambas-user@... > https://lists.sourceforge.net/lists/listinfo/gambas-user > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Gambas-user mailing list Gambas-user@... https://lists.sourceforge.net/lists/listinfo/gambas-user |
|
|
Re: Breaking processesDimitris Anogiatis ha scritto:
> Hey M, > > to stop the execution of a for loop all you have to do is check for a > condition then use break > > for example > > > PUBLIC SUB FCopy() > DIM i AS Integer > Dim stopLoop as Boolean > DIM filepaths AS String[] > ........................' the array filepaths is filled with contents > FOR i=0 To filepaths.Count-1 > > if stopLoop = False THEN > SHELL "cp -f " & filepaths[i] & " /home/destination" > Else > BREAK > ENDIF > NEXT > To do so, you must put a button on the form. To let this button react to mouse clicks, you must use a WAIT inside the loop - without WAIT, the button gets the click, but delays its reaction until your current subroutine finishes - so you don't break/cancel anything. Then, your button must do something your current loop can check. This is a global variable - it can not be one declared inside the subroutine, because nothing from the extern can interfere with local variables. The event handler for the cancel button can set this global variable, and the copy loop can check this variable. These information are not 100% accurate - but you get the point. To summarize, you put a btCancel button on the form, and use the following code: private StopLoop as boolean ' global shared variable public sub fcopy() ... ... StopLoop = false; ' always set a value to variables... FOR i=0 To filepaths.Count-1 WAIT ' otherwise btCancel does not react to clicks in the correct time if StopLoop then BREAK ' WHO set this variable? The next subroutine... SHELL .... ... end public sub btCancel_Click() StopLoop = true ' clicking btCancel comes here and sets the global variable end I didn't tested this code, but it should work. Best regards, Doriano >> How can I stop the execution of a loop which includes shell command for >> copying files? >> >> Example: >> PUBLIC SUB FCopy() >> DIM i AS Integer >> DIM filepaths AS String[] >> ........................' the array filepaths is filled with contents >> FOR i=0 To filepaths.Count-1 >> SHELL "cp -f " & filepaths[i] & " /home/destination" >> NEXT >> >> END >> >> I'd like to add a Cancel button which would break the loop.Thanks! >> >> ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Gambas-user mailing list Gambas-user@... https://lists.sourceforge.net/lists/listinfo/gambas-user |
|
|
Re: Breaking processesThanks, I think it should really work! I'll check it and write again if it
won't. ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Gambas-user mailing list Gambas-user@... https://lists.sourceforge.net/lists/listinfo/gambas-user |
| Free embeddable forum powered by Nabble | Forum Help |