Topic
1 reply Latest Post - ‏2013-10-12T21:25:54Z by JonPeck
Lycurgue
Lycurgue
1 Post
ACCEPTED ANSWER

Pinned topic Macro expansion in path

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

Hi,

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'
!ENDDEFINE.

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

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

Is there a way to do this ?

Thanks,

François Maurice

 

 

  • JonPeck
    JonPeck
    84 Posts
    ACCEPTED ANSWER

    Re: Macro expansion in path

    ‏2013-10-12T21:25:54Z  in response to Lycurgue

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

    SET MPRINT ON.

    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.
    !chConstr.

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