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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Macro Menu Mess

Status
Not open for further replies.

rseegraves

Technical User
Jul 2, 2008
1
US
I am trying to create a "menu" for reports from within the COGNOS Script Editor. I almost have it there. Here are the Macros I have created so far (actually these are functional, but much smaller versions of the "real" files):

Here is the main menu (MINI-MENU.MAC):

Sub Main

Begin Dialog MainDlg 8,0,363,163, "Basic Package of Reports - Main Menu"
Picture 10,9,333,42, "C:\GBASRPT\menu.bmp",0,.dlgPicture
Text 20,55,150,11,"Impromptu Basic Package of Reports:",.dlgText
Text 30,70,94,11,"Select a category:",.dlgText3
Button 40,90,150,17,"Type I Reports:",.bnOne
Button 200,90,150,17,"Type II Reports",.bnTwo
Button 40,111,150,17,"Type III Reports",.bnThree
Button 40,132,150,17,"Adhoc Reporting",.bnRep
Button 200,111,150,17,"Other Reports",.bnMisc
Button 200,132,150,17,"E&XIT",.bnExit
End Dialog

'Define Objects needed
'---------------------
Dim ImpApp as Object
Dim ImpRep as Object
Dim StartDlg as MainDlg
Dim DlgRet as Integer

'Invoke the dialog box, capture return value in DlgRet variable
'--------------------------------------------------------------
DlgRet=Dialog(StartDlg)

'Create the Impromptu Application Object - starts Imp
'----------------------------------------------------
'Set ImpApp=CreateObject("CognosImpromptu.Application")

'Check to see is Exit button pressed
'-----------------------------------
Do while (DlgRet <> 6)

'Use Case to decide which report to run
'--------------------------------------
Select Case DlgRet

Case (1)
Call One
Case (2)
Call Two
Case (3)
Call Three
Case (4)
Call Rep
Case (5)
Call Misc
Case (6)
End Select

'Re-display the dialog
'---------------------
DlgRet=Dialog(StartDlg)

Loop

'Quit Impromptu
'--------------
'ImpApp.Quit
Set ImpApp=Nothing

End Sub

Here is the first submenu (ONE.MAC):

Sub Main

Begin Dialog MainDlg 8,0,363,121, "Type I Reports"
Picture 10,10,333,42, "C:\GBASRPT\menu.bmp",0,.dlgPicture
Text 20,55,150,11,"Type I Reports:",.dlgText
Text 30,70,94,11,"Select a Report to Open:",.dlgText3
Button 40,90,150,17,"Report I-01",.bnF01
Button 200,90,150,17,"E&XIT",.bnExit
End Dialog

'Define Objects needed
'---------------------
Dim ImpApp as Object
Dim ImpRep as Object

'Define a dialog object as 'type' of the above dialog
'and define an integer to capture the return value of
'the button pressed (or other control activated)
'----------------------------------------------------
Dim StartDlg as MainDlg
Dim DlgRet as Integer

'Invoke the dialog box, capture return value in DlgRet variable
'--------------------------------------------------------------
DlgRet=Dialog(StartDlg)

'Create the Impromptu Application Object - starts Imp
'----------------------------------------------------
Set ImpApp=CreateObject("CognosImpromptu.Application")

'Check to see is Exit button pressed
'-----------------------------------
Do while (DlgRet <> 2)

'Make Impromptu visible
'----------------------
ImpApp.Visible 1

'Use Case to decide which report to run
'--------------------------------------
Select Case DlgRet

Case (1)
Set ImpRep=ImpApp.OpenReport("C:\RPT\REPORT I.imr")
Case (2)
End Select

'Re-display the dialog
'---------------------
DlgRet=Dialog(StartDlg)

Loop

'Quit Impromptu
'--------------
ImpApp.Quit
Set ImpApp=Nothing

End Sub

The second (TWO.MAC):

Sub Main

Begin Dialog MainDlg 8,0,363,121, "Type II Reports"
Picture 10,10,333,42, "C:\GBASRPT\menu.bmp",0,.dlgPicture
Text 20,55,150,11,"Type II Reports:",.dlgText
Text 30,70,94,11,"Select a Report to Open:",.dlgText3
Button 40,90,150,17,"Report II-01",.bnF01
Button 200,90,150,17,"E&XIT",.bnExit
End Dialog

'Define Objects needed
'---------------------
Dim ImpApp as Object
Dim ImpRep as Object

'Define a dialog object as 'type' of the above dialog
'and define an integer to capture the return value of
'the button pressed (or other control activated)
'----------------------------------------------------
Dim StartDlg as MainDlg
Dim DlgRet as Integer

'Invoke the dialog box, capture return value in DlgRet variable
'--------------------------------------------------------------
DlgRet=Dialog(StartDlg)

'Create the Impromptu Application Object - starts Imp
'----------------------------------------------------
Set ImpApp=CreateObject("CognosImpromptu.Application")

'Check to see is Exit button pressed
'-----------------------------------
Do while (DlgRet <> 2)

'Make Impromptu visible
'----------------------
ImpApp.Visible 1

'Use Case to decide which report to run
'--------------------------------------
Select Case DlgRet

Case (1)
Set ImpRep=ImpApp.OpenReport("C:\RPT\REPORT I.imr")
Case (2)
End Select

'Re-display the dialog
'---------------------
DlgRet=Dialog(StartDlg)

Loop

'Quit Impromptu
'--------------
ImpApp.Quit
Set ImpApp=Nothing

End Sub

The third (THREE.MAC):

Sub Main

Begin Dialog MainDlg 8,0,363,121, "Type III Reports"
Picture 10,10,333,42, "C:\GBASRPT\menu.bmp",0,.dlgPicture
Text 20,55,150,11,"Type III Reports:",.dlgText
Text 30,70,94,11,"Select a Report to Open:",.dlgText3
Button 40,90,150,17,"Report III-01",.bnF01
Button 200,90,150,17,"E&XIT",.bnExit
End Dialog

'Define Objects needed
'---------------------
Dim ImpApp as Object
Dim ImpRep as Object

'Define a dialog object as 'type' of the above dialog
'and define an integer to capture the return value of
'the button pressed (or other control activated)
'----------------------------------------------------
Dim StartDlg as MainDlg
Dim DlgRet as Integer

'Invoke the dialog box, capture return value in DlgRet variable
'--------------------------------------------------------------
DlgRet=Dialog(StartDlg)

'Create the Impromptu Application Object - starts Imp
'----------------------------------------------------
Set ImpApp=CreateObject("CognosImpromptu.Application")

'Check to see is Exit button pressed
'-----------------------------------
Do while (DlgRet <> 2)

'Make Impromptu visible
'----------------------
ImpApp.Visible 1

'Use Case to decide which report to run
'--------------------------------------
Select Case DlgRet

Case (1)
Set ImpRep=ImpApp.OpenReport("C:\RPT\REPORT I.imr")

Case (2)
End Select

'Re-display the dialog
'---------------------
DlgRet=Dialog(StartDlg)

Loop

'Quit Impromptu
'--------------
ImpApp.Quit
Set ImpApp=Nothing

End Sub

The fourth (a bit larger pared down sample) (MISC.MAC):

Sub Main

Begin Dialog MainDlg 8,0,363,184, "Basic Package of Reports - Miscellaneous"
Picture 10,10,333,42, "C:\GBASRPT\menu.bmp",0,.dlgPicture
Text 20,55,150,11,"Miscellaneous Reports:",.dlgText
Text 30,70,94,11,"Select a Report to Open:",.dlgText3
Button 40,90,150,17,"Misc Rep-01",.bnM01
Button 40,111,150,17,"Misc Rep-02",.bnM02
Button 40,132,150,17,"Misc Rep-03",.bnM03
Button 40,153,150,17,"Misc Rep-04",.bnM04
Button 200,90,150,17,"Misc Rep-05",.bnM05
Button 200,111,150,17,"Misc Rep-06",.bnM06
Button 200,132,150,17,"Misc Rep-07",.bnM7
Button 200,153,150,17,"E&XIT",.bnExit
End Dialog

'Define Objects needed
'---------------------
Dim ImpApp as Object
Dim ImpRep as Object

'Define a dialog object as 'type' of the above dialog
'and define an integer to capture the return value of
'the button pressed (or other control activated)
'----------------------------------------------------
Dim StartDlg as MainDlg
Dim DlgRet as Integer

'Invoke the dialog box, capture return value in DlgRet variable
'--------------------------------------------------------------
DlgRet=Dialog(StartDlg)

'Create the Impromptu Application Object - starts Imp
'----------------------------------------------------
Set ImpApp=CreateObject("CognosImpromptu.Application")

'Check to see is Exit button pressed
'-----------------------------------
Do while (DlgRet <> 8)

'Make Impromptu visible
'----------------------
ImpApp.Visible 1

'Use Case to decide which report to run
'--------------------------------------
Select Case DlgRet

Case(1)
Set ImpRep=ImpApp.OpenReport("C:\RPT\Report I.imr")
Case(2)
Set ImpRep=ImpApp.OpenReport("C:\RPT\Report I.imr")
Case(3)
Set ImpRep=ImpApp.OpenReport("C:\RPT\Report I.imr")
Case(4)
Set ImpRep=ImpApp.OpenReport("C:\RPT\Report I.imr")
Case(5)
Set ImpRep=ImpApp.OpenReport("C:\RPT\Report I.imr")
Case(6)
Set ImpRep=ImpApp.OpenReport("C:\RPT\Report I.imr")
Case(7)
Set ImpRep=ImpApp.OpenReport("C:\RPT\Report I.imr")
Case(8)
End Select

'Re-display the dialog
'---------------------
DlgRet=Dialog(StartDlg)

Loop

'Quit Impromptu
'--------------
ImpApp.Quit
Set ImpApp=Nothing

End Sub

And the last: (REP.MAC)

Sub Main

Dim ImpApp as Object

Set ImpApp=CreateObject("CognosImpromptu.Application")

ImpApp.Visible 1

DoEvents

SendKeys "%FO"

End Sub


I have a couple of problems/questions.

The main problem is that the macros work just fine when I run them from the COGNOS script editor. And all of the submenus (with the exception of the last one) work just fine when called individually from within Impromptu (I'm testing in 7.4 MR 2). But, when I attempt to run the first macro - MINI-MENU.MAC, I get a dialog box that pops up and says "Error in MINI-MENU.MAC, Code: -2002 Line:44, "Unknown function: One". This is repeated for Two, Three, Rep and Misc. The only difference is that the line number changes.

I am not a programmer and basically constructed this from the excellent examples I found on this site.

I've been through the help and documentation with the product and, since I am not a programmer, it has been much less than helpful. If anyone here can assist me, I would be truly greatful.

Thank you so much.
 
rseegraves,
If I understand your post correctly, you've got separate macros, yet wish to call them from the main one.
In which case, the CALL function requires the subsidary macros to be sub-programs within the same file.

See the Macro Reference for CALL (within CognosScript Editor, Help> Macro Language Help)- there is a sample that will illustrate the point.

Happy Friday!

soi là, soi carré
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top