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

Clearing all app activity and variables . . .

2020-10-12-182030

All --

I would like a way to clear out all of the activity of an APP.

It seems that I can unload the APP but that the variables that are created within the APP persist until the APP is EDITED in the PROJECT WORKBENCH

Is there a statement that will clear all APP related material from memory of IMAGE-PRO and the PROJECT WORKBENCH so that it is basically as fresh as it is immediately after a LOAD?

Thanks.

-- Matt


Best Answer

  • Answer ✓
    Hi Matt,

    The short answer is no, there is no built-in way to return app to the initial state without unloading and loading the macro project.

    Depending on where your variables are declared, they could be initialized at different steps. All variables defined in the Modules (e.g. Module1.vb) are initialized when the project is loaded. The variables that are defined in App or Form files (e.g. App1.vb) could be initialized when the app dialog shows app, when you click the app's icon on the Apps tab (in Me.Load event handler)

    So, to initialize/reset all you variables when you or customer needs it you should create a "Reset" function and assign it to a button in your app. Many of our apps use that approach, here is how it's implemented in the Fiber Separation app:



    Yuri

Answers

  • Hi Matt,

    If you want to go to the initial state of the app without unloading/loading of the app, you should create a "Reset" sub/function which sets proper initial values to all your variables (and could be called from the UI when you need it, assign a button to it). 
    It's similar to what we have in Image-Pro ribbon, like "Reset measurement options", "Reset classes",...

    Yuri

  • 2020-10-13-093702

    Yuri --

    Thank you for your suggestion.

    I think I did not make my self clear or I am not understanding some of the interaction of an APP and IMAGE-PRO.

    When we are editing an APP / PROJECT in the WORKBENCH, the character of the UI and the VARIABLES is suspended.

    When we LOAD an APP / PROJECT in the WORKBENCH, the APP / PROJECT is in a "CLEAN" INITIAL STATE determined only by CODE within and with no USER INTERACTION.  When we then OPEN the APP via the APPS RIBBON, the relationship between IMAGE-PRO and the APP / PROJECT is in a RUNNING STATE and the VARIABLES and UI appear as set up in the CODE with no influence by the USER.  When we CLOSE the APP / PROJECT, the relationship between IMAGE-PRO and the APP / PROJECT does not seem to return completely to the ""CLEAN" INITIAL STATE. 

    Sometimes this is a good thing because the values of VARIABLES and the state of CONTROLS is not cleared automatically because the UI is CLOSED and a CLOSE / OPEN maintains VARIABLES and UI SETTINGS. 

    Sometimes this is a bad thing because the values of VARIABLES and the state of CONTROLS is not cleared automatically because the UI is CLOSED and a CLOSE / OPEN maintains VARIABLES and UI SETTINGS and does not appear after a CLOSE / OPEN as they appear after a EDIT / LOAD / OPEN.

    Is there a way to return the APP / PROJECT to the "CLEAN" INITIAL STATE seen after EDIT / LOAD / OPEN as if it was never taken up to the RUNNING STATE?

    Thanks.

    -- Matt
  • 2020-10-13-181034

    Yuri --

    Thank you for the information and the suggestion.

    I will implement that.

    Thanks again.

    -- Matt


Sign In or Register to comment.