Skip to main content
1-Visitor
February 4, 2010
Question

Can you pass parameters to a macro

  • February 4, 2010
  • 2 replies
  • 7485 views
I'm used to a different macro programming language in which you can have 1 macro do several different things by passing parameter(s) along with the macro name - e.g. macro_name 'yes' The macro then declares the parameter(s) e.g. parameter yes_no The parameter yes_no is then a variable yes_no with a value of 'yes' The macro then uses this variable to determine an action later on. For example, I have a macro that changes a drawing and saves it down again, but I now find I want a very similar macro that does everything except save the drawing down again. With a parameter, I could include an if statement in the macro to either save the drawing or not depending on the value of the parameter. Otherwise I will have to either copy the macro twice or split it into bits and run as separate macros Is there something similar to this in Isodraw? I have looked but can't find anything, though the terminology may be different.

    2 replies

    12-Amethyst
    February 4, 2010
    I'm not sure how you are planning to specify the parameter. My approach is to basically break it apart as you mention. It can be done at a high level though. Have a global variable that is set and then basically three macros. 1) Your main macro with the addition of an "if" statement surrounding your save down coding. For our purposes let's refer to this as a submacro called "Change_and_Maybe_Save_Down" (long, but descriptive). 2 & 3) Something similar to this...
    209c292858
    and then another such as...
    209c292858
    Then just check the value of this variable in your if statement used in Change_and_Maybe_Save_Down.
    TimSharp1-VisitorAuthor
    1-Visitor
    February 4, 2010
    Yes this is a good way of doing it. A global variable will do the same job as a parameter. Unfortunately I always compare things to ME10 and try to do things a similar way - I programmed ME10 for over 20 years so it's ingrained!
    1-Visitor
    February 5, 2010

    In IsoDraw 7.1 you can pass parameters to submacros like this:

    SubMacro Change_drawing( Boolean save_down )
    If ( save_down ) Then
    # Change and Save Down ...
    Else
    # Change only ...
    End If
    End SubMacro

    Macro Test_Change_drawing
    Run Change_drawing( true )
    # or
    Run Change_drawing( false )
    End Macro

    1-Visitor
    July 20, 2010

    Hi,

    Actually I have two problems about this topic :

    - First, I can't see the code examples quoted in this topic, all I can see is :

    In IsoDraw 7.1 you can pass parameters to submacros like this:

    d008373291

    - Next, I really need to pass parameters to a macro, but in a command line like this :

    C:\Program Files\PTC\Arbortext IsoDraw 7.1\Program\IsoDraw71.exe file.cgm -macro macroName(parameter)

    The PTC support told me that was possible, but they are not able to tell me how to write the macro to get the parameters. I tried several ways :

    -> Macro macroName(String param) : I have a 'parameter error ""'
    -> Macro macroName(define param as String) : isodraw crashes
    -> Macro macroName(param) : isodraw crashes

    Can anyone help me, please?

    Thanks

    Damien

    1-Visitor
    July 21, 2010

    Hi,

    I restored the code snipplet above. This:

    Macro macroName(String param)

    # Do something with param

    End Macro

    would be the right thing in your case. To resolve the parameter error, check the quotes in the command line.

    E.g. this should work:

    IsoDraw71.exe file.cgm -macro macroName("ABCD")

    Please note that environment variables in the cmd shell are resolved without quotes, so they also need to be quoted,

    if you want to pass them as string parameters to a macro:

    IsoDraw71.exe file.cgm -macro macroName("%MY_ENVIRONMENTVAR%")

    1-Visitor
    July 21, 2010

    Hi,

    Well, my new test seems to work... I'm trying with my whole treatment.

    Thank you,

    Damien