Menu

#985 Setoverwrite settings do not apply when call a function

closed-invalid
Scripting (211)
5
2010-05-15
2010-05-13
Anonymous
No

Version 2.36
thavilan@suss.com

I'm having a problem with SetOverwrite and I don't see anything else relating to this.

My install sets several configuration files into a current directory and a defaults directory. When I write into the current directory, I don't want to overwrite existing files (in the case of an upgrade). I always want to overwrite the default directory.

So I do something like:

SetOutPath "${CONFIG_DEST_FOLDER}\Current\ SetOverwrite off
Call WriteConfigFiles

and then

SetOutPath "${CONFIG_DEST_FOLDER}\Default\ SetOverwrite on
Call WriteConfigFiles

But when I do this, it always writes the config files. If I move the SetOverwrite off into the WriteConfigFiles routine, it won't overwrite existing files, but of course I want it to in the second case.

WriteConfigFiles looks like:

Function WriteConfigFiles
File ${CONFIG_SRC_FOLDER}\HMI1.config
File ${CONFIG_SRC_FOLDER}\HMI2.config
File ${CONFIG_SRC_FOLDER}\HMI3.config
File ${LIB_COMMON_FOLDER}\MachineConfiguration\Machine.xslt
File ${LIB_COMMON_FOLDER}\MachineConfiguration\Machine.xsd
File ${CONFIG_SRC_FOLDER}\Unit1.config
File ${CONFIG_SRC_FOLDER}\Unit2.config
File ${CONFIG_SRC_FOLDER}\Unit3.config
FunctionEnd

Discussion

  • Amir Szekely

    Amir Szekely - 2010-05-15
    • labels: 732400 --> Scripting
    • status: open --> closed-invalid
     
  • Amir Szekely

    Amir Szekely - 2010-05-15

    SetOverwrite is a compile-time command and not runtime. If you want the same file to be written with different overwrite methods, you have to use File twice, each time with a different SetOverwrite before it.

    In your code, duplicate the WriteConfigFiles function and use a different SetOverwrite at its top. You can also use a macro to make it simpler. You are better off using macros for file extraction anyway, for progress.

    !macro WriteConfigFiles OVERWRITE_MODE
    SetOverwrite ${OVERWRITE_MODE}
    File ...
    !macroend

     

Log in to post a comment.