Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there a "skip" step or a way to "skip" in a macro? 1

Status
Not open for further replies.

jimicron2

Technical User
May 22, 2007
12
US
Hi all,

Is there a way to skip steps within a macro?

For example, let's say my macro is set up to export data to 6 different .csv files. I run this on a weekly basis. However, let's say some weeks I don't want to update the 5th (for example) .csv file but I do want to update 1-4 and the 6th. Is there a capability or a way within a macro to provide this sort of "out" or way to run the macro, but be able to exclude certain steps?

Thanks a lot!

JIM
 
A possibility could be that you give along a parameter or multiple parameters with your macro.

For example you could give along as a parameter the number 5 when calling the macro. And you could then put every export to a macro under an "If" statement in which you kind of say: If the parameter is not equal to one, then export the first csv. If the parameter is not equal to two, then export the second csv.

If you do it like this, then the 5th export will not be done when the parameter you give along is equal to 5.

I hope this helps.
 
JDAEMS

Can you give an example of what this would actually look like in a macro? I am not quite following, but maybe with an example, it will help and then I can tweak it.
Thanks!
JIM
 
CognosScript has the ability to pass the parameters supplied by the user when invoking a macro from the command line. Accessing the command line parameters in a macro is accomplished by using the Command$ function.

An example of the command line syntax to pass parameters to a macro is:

<install path>\cognos\cer4\bin\runmac32.exe <path to macro>\macro.mac Hello

Where <install path> is the path to the installation directory of the Cognos software and <path to macro> is the path to the directory location where the macro to be executed is found.

In the macro, the parameter is retrieved with the Command$ function. The syntax to for calling the Command$ function and placing the result into a variable is:

Variable = Command$

The following is an example of how to retrieve the command-line parameters supplied to the macro and display them in a dialog box on the screen:


''''''''''' Start of macro

Sub Main()
Dim RetString as String
RetString = Command$
Msgbox RetString
End Sub

''''''''''' End of Macro

Return Value:

The result of the Command$ function is a String containing all parameters supplied at the command line. If multiple parameters have been passed through command line, the Macro Developer will be required to develop to parse the resulting String. Parsing the String will only be required if the macro must utilize specific parameter values as opposed to the complete String.

Steps:

-Launch the CognosScript Editor
-Copy and Paste the macro found in this document, into the CognosScript Editor text window.
-Save the macro to a file entitled macro.mac
-Run the CognosScript Editor's 'check' option.
-From a command prompt, issue the following command:
<install path>\cognos\cer4\bin\runmac32.exe <path to macro>\macro.mcx Hello

A Dialog Box containing 'Hello' (without the apostrophes) should appear on the screen.
 
Sorry for my lack of knowledge, but I do not see CognosScript Editor in Planning-Analyst. Is this for Planning-Analyst? If so, how do I open Script Editor?
Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top