Home Image-Pro Automation (Macros, Apps, Reports)
Options

STOPPING a LOOP within a SUBROUTINE within a PROJECT

All --

I am creating a project that is intended to process all of the images within a folder.

Everything is working well but the customer / end user would like a mechanism added which will allow them to STOP the APPLICATION before it has processed all of the images in the folder.

I've tried creating a STOP BUTTON and a STOP CHECKBOX but the code "behind" these controls is not reliably executed and therefore I cannot create a mechanism to stop my loop.

The ESC key achieves the goal of stopping the PROJECT SOFTWARE but it has to be restarted from within the PROJECT WORKBENCH or by restarting PREMIER.

Is there a graceful way of doing what our PREMIER CUSTOMER wants to do?

This may be an application for the code PIERRE supplied on 21-APR-2014

    Public Function ReloadApp() As SimpleScript
        ReloadApp = New SimpleScript

        With Automate.ScriptingCommands.AppGadget(ReloadApp)
            .AppFile = "Project2\App1.vb"
            .Reload = True
            .CheckState = MediaCy.IQL.Application.McCommand.mcCheckState.Checked
            .Run()
        End With

    End Function

But I don't understand the proper way to wire this into my project.

Thanks.

-- Matt

Best Answer

  • Options
    Answer ✓
    Matt,

    You have a couple of options. First, I would encourage you to look at the batch processing feature in Premier which uses the task manager to allow cancelling tasks after they have been scheduled.

    If this approach doesn't work for you, I suggest that you look at the following macro. It uses the Premier progress meter to give feedback on the current status while also allowing to cancel the processing using the ESC key in Premier. In this case the project is not stopped but the macro is simply interrupted and exits cleanly. Note that the focus needs to be on the Premier main window.

    Lastly if you want something more visual, you can certainly add a Cancel button to your App, the only requirement then, is that you call DoEvents regularly so that Windows can handle the user interactions with your button. The drawback with this approach is that it enables all the Premier controls which you don't necessarily want.

    Pierre

        Sub ProcessWithProgressMeter
            Dim images() As String = system.IO.Directory.GetFiles(ThisApplication.Path(mcPathType.mcptSampleImages),"*.tif",System.IO.SearchOption.AllDirectories)
            Dim busy As McBusyState = ThisApplication.SetBusyState(Interop.mcApplicationCursor.mcacWait,True)
            busy.SetProgressInfo("Processing images...",Interop.mcProgressAllowCancel.mcpacTopLevelCancelOnly,0,images.Length-1)
            For i As Integer = 0 To images.Length-1
                If busy.SetProgress(i) Then
                    Exit For
                End If
                ThisApplication.Documents.OpenFile(images(i),False)
                ThisApplication.Documents.CloseAll()
            Next
        End Sub
    


Answers

  • Options
    Pierre --

    Thank you for your three suggestion.

    #1

    This software is not appropriate for use with the PREMIER BATCH PROCESSING TOOL.

    #2

    I'm delivering the software today.  If the customer requests further modifications, I'll see if I can re-engineer it to use this method.

    #3

    Before submitting my question, I tried the method you suggested in your last paragraph.  Occasionally my STOP BUTTON was handled properly but usually it was ignored until the LOOP had completed.  This was true even with a liberal distribution of DOEVENTS throughout the appropriate sections of the software.

    #4???

    Would it be possible to wire in a STOP ALL PROJECTS button into PREMIER that would essentially do an EXIT ALL on all running software or set a SYSTEM VARIABLE that the software could watch for?  IMAGE-PRO PLUS kind of did this if you attempted to shut down the software if a program was running.  I think I tried this with PREMIER but I don't thing the results were the same.

    Thanks again.

    -- Matt


Sign In or Register to comment.