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

IPX FILES and MACRODIR FUNCTION ISSUES

All --

I am a heavy user of the MACRODIR FUNCTION.

The HELP FILE shows the following:

"MacroDir Function

Syntax                  MacroDir

Group                   Flow Control

Description           Return the directory of the current macro. A run-time error occurs if the current macro has never been saved."

I use MACRODIR in code meant to SAVE and LOAD files affiliated with my projects.

In a project I'm working on right now, I want the project to be able to SAVE and LOAD an INI FILE that will store settings made by the user within the APPLICATION.

Unfortunately the MACRODIR FUNCTION does not work when it is within a PROJECT that has been saved as an IPX FILE using the options within

    PROJECT WORKBENCH + FILE + PACKAGE

I found this out when testing a suggestion from PIERRE that is on the FORUM at

    http://forums.mediacy.com/discussion/comment/532/#Comment_532

Is there a work around for this that will allow me to use the options within the

    PROJECT WORKBENCH + FILE + PACKAGE

If not, is there another way for me to COMPILE or ENCRYPT a PREMIER PROJECT / APPLICATION / MODULE?

Thanks.

-- Matt

Best Answers

  • All --

    I have created a WORKAROUND that seems appropriate for the situation.

    I have created a

        AlcesMacroDir Function

    as shown below.

    In situations where the native

        MacroDir Function

    is not available because the PROJECT is saved in an IPX file, I can add the

        AlcesMacroDir Function

    to the PROJECT and then modify any statements that include

        MacroDir

    to instead include

        AlcesMacroDir

    and then the PROJECT will be functional again.

    Unfortunately this will cause any files generated by the PROJECT CODE to be stored in a FOLDER created in the FOLDER designated by

        System.Environment.SpecialFolder.CommonApplicationData

    On my WINDOWS 7 PRO MACHINE that FOLDER is

        C:\ProgramData

    so within my PREMIER PROJECT, the AlcesMacroDir Function returns

        C:\ProgramData\Alces Imaging and Automation

    If someone sees a better solution, please let me know.

    Thanks.

    -- Matt

    *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
        Private Function AlcesMacroDir () As String
    
            '--- Set up the FOLDER that will be used instead of the MACRODIR FOLDER
    
            'Learn the COMMON APPLICATION DATA FOLDER
            Dim My_F0 As String = _
                system.Environment.GetFolderPath _
                    (System.Environment.SpecialFolder.CommonApplicationData)
    
            'Learn the COMPANY NAME
            Dim My_F1 As String = _
                "Alces Imaging and Automation"
    
            'Determine whether a COMMON APPLICATION DATA FOLDER exists for the COMPANY
            If System.IO.Directory.Exists( My_F0 & "\" & My_F1 ) = False _
                Then
                    'Make a COMMON APPLICATION DATA FOLDER for the COMPANY
                    MkDir _
                        ( My_F0 & "\" & My_F1 )
                End If
    
            'Return the COMMON APPLICATION DATA FOLDER for the COMPANY
            AlcesMacroDir = _
                My_F0 & "\" & My_F1
    
        End Function
  • Answer ✓
    Matt,

    You can store pretty much anything in application settings. They are not stored in the registry but in the identity file (.IDT) instead which is in a hidden directory C:\Users\<USER>\AppData\Roaming\Media Cybernetics\<PRODUCT NAME>\<PRODUCT VERSION>\Resources\Identities. This file contains all the identity settings, it is not meant to be used directly.

    Pierre 

Answers

  • Matt,

    MacroDir is not available for packaged projects because these projects come from an IPX file not a directory. That said we should still be able to help you achieve your goal. We typically store settings in a folder that can be accessed with ThisApplication.Path(mcPathType.mcptConfigurationFiles). One advantage of using this approach is that you can add these files to your IPX (on the project page) and they will be installed automatically in that same folder when the project is loaded on a different machine. Would that work for you? If not, can you describe what would be your preferred approach when dealing with an IPX project which does not have its own directory for storing things.

    Pierre
  • Pierre --

    Thank you for your response.

    In the case of the current PROJECT that I'm working on, the PROJECT needs to save the values / states of some TEXTBOXES and CHECKBOXES in an INI FILE when the PROJECT EXITS and then load these values / states when the PROJECT LOADS.  This saves the USER the effort of setting these values / states every time the software is started.

    When the PROJECT is run from the discrete files (DESIGNER.VB, RESX, VB, and IPP) the MACRODIR FUNCTION allows the INI FILE to be saved and loaded adjacent to the discrete PROJECT files.

    If MACRODIR could be modified to give the PATH to the FOLDER that holds the IPX file rather then an error, that would be super.  Then the INI FILE (or whatever other support file) could be saved and loaded from the same folder that holds the IPX FILE.

    I added    
        MsgBox ThisApplication.Path(mcPathType.mcptConfigurationFiles)
    to my PROJECT to see what it generates and the result was

       

    when run from PREMIER 9.1.4.

    Using this CONFIGURATION FILES FOLDER as a location for the INI FILE is an option. 

    On the PRO SIDE:

    -- this is a FOLDER that is known to exist and is set PER USER

    On the CON SIDE:

    -- the PROJECT FILES (IPX or VB + + +) would not be in the same FOLDER as the INI FILE
    -- each user would have to establish the HARDWARE PARAMETERS that are being stored in the INI FILE
    -- backing up the software would be more complicated for the user because all of the files are not in one location

    I tried to see if the MACRODIR could be used as a PLAN A and the CONFIGURATION FILES FOLDER could be used as a PLAN B if the MACRODIR FUNCTION did not work with:

                Try
                    Debug.Print "MacroDir"
                    Debug.Print MacroDir
                Catch
                    Debug.Print "ThisApplication.Path(mcPathType.mcptConfigurationFiles)"
                    Debug.Print ThisApplication.Path(mcPathType.mcptConfigurationFiles)
                Finally
    
                End Try
    
    but the PROJECT would not load.

    I hope there is a workaround that will keep all of the files for this PROJECT in the same FOLDER and allow the PROJECT to be packaged as an IPX FILE.

    Thanks.

    -- Matt
  • FORUM --

    Any further thoughts on a mechanism that can be used within PREMIER PROJECT saved in an IPX file that will give the CODE the name of the FOLDER that the PROJECT is being run from?

    If so, the PROJECT can be written so that the PROJECT and the INI FILE that supports it will be in the same FOLDER.

    If not, the PROJECT can be written with

        ThisApplication.Path(mcPathType.mcptConfigurationFiles)

    but this will mean that the PROJECT and the INI FILE that supports it will be in different FOLDERS.

    Thanks.

    -- Matt
  • Matt,

    MacroDir is a built-in function of the basic interpreter so we cant change it. Using the path property seems like a good idea. For cases where the settings file only contains optional settings you also have the option of using application settings which are exposed as ThisApplication.Settings and are saved as part of the identity.

    Pierre
  • Pierre --

    Thank you for your response and your suggestion.

    I'll look into using

        ThisApplication.Settings

    I see that I have used this before with

            'Make sure the SAVE SELECTED FEATURES OPTION is OFF within FEATURES MANAGER
            ThisApplication.Settings("Application", "FeaturesManager").Set("cbSelected", False)

    but I'll need to do some R&D about how to use

        ThisApplication.Settings

    to store NON-PREMIER VARIABLES.

    When you say that these variables are saved as part of the identity, does that mean they are saved in the WINDOWS REGISTRY? 

    If yes, can you point me to the REGISTRY KEY that they would be stored in?

    If not, where are they saved?

    Thanks again.

    -- Matt

  • Pierre --

    Thanks for the information.

    I'll look into this.

    Thanks again.

    -- Matt
Sign In or Register to comment.