• 1 reply
  • Latest Post - ‏2013-10-12T21:25:54Z by JonPeck
1 Post

Pinned topic Macro expansion in path

‏2013-10-12T14:59:15Z |


I'm trying to define some FILE HANDLE with macro expansion. I tried many combinations with quotes or not but without success. Here's one of them :

DEFINE !ProjtName() '001_FirstProject'

DEFINE !AbsPath() 'D:\dossiers\SCV\Client76072_Francois_Maurice\scvadmin76072\Depot70555_DemonstrationII\Racine\'

DEFINE !chConstr()
FILE HANDLE chConstr NAME = !CONCAT(!AbsPath, !ProjtName, '\Analysis\Results').

Is there a way to do this ?


François Maurice



  • JonPeck
    87 Posts

    Re: Macro expansion in path


    There are several problems here.  In order to understand what the macro is generating, use


    before calling the macro.  That will show you what code is generated.

    First problem: you have quoted strings, and you need to remove those quotes before concatenating by using !UNQUOTE and then use !QUOTE around the result to wind up with a quoted literal.

    Second: You don't want line breaks in the macro definition, so I moved the !ENDDEFINE to the same line.

    Third: You need to force the prior macro definitions to be evaluated in the last macro expansion, so I inserted an !EVAL call.

    The code below resolves these issues.

     DEFINE !ProjtName() '001_FirstProject' !ENDDEFINE.

    DEFINE !AbsPath() 'D:\dossiers\SCV\Client76072_Francois_Maurice\scvadmin76072\Depot70555_DemonstrationII\Racine\' !ENDDEFINE.

    set mprint on.
    DEFINE !chConstr()
    FILE HANDLE chConstr NAME = !quote(!CONCAT(!unquote(!eval(!AbsPath)), !unquote(!eval(!ProjtName)), !unquote(!eval('\Analysis\Results')))). !ENDDEFINE.

    Doing this sort of thing with Python programmability is much easier.