Title: RE: (ROSE) RoseScript and VB
Hello Dan,
 
        One cannot pass command-line parameters/information via the CreateObject/CreateObjectInstance to the Rose application object. However, I have come up with a couple of workarounds to pass information/parameters from an external VB program to the Rose application/object and have your Rosescript read those parameters:
 
1. If you are going to make use of CreateObject to instantiate a Rose application object, then one alternative to doing this would be by simply launching Rose.exe, from your VB program, with some parameters:
' // in VB program:
    Dim taskID As Integer, iRose As Object, strParam As String
    strParam = "Test parameter value from VB"
 
    taskID = Shell("C:\Program Files\Rational\Rose\rose.exe """ & strParam & """""", vbNormalFocus)
            'an extra pair of qoutes as a workaround for pending defect in Rose:-------^

    On Error Resume Next
    Set iRose = GetObject(, "Rose.Application")
    If iRose Is Nothing Then
      ' Set roseApp = CreateObject("Rose.Application")
      MsgBox "Rose not launched!"
      Exit Sub
    End If
    iRose.ExecuteScript "C:\Temp\test.ebs"
 
' // and the test.ebs:
    Sub Main
        MsgBox RoseApp.CommandLine   ' // This would pop up: "Test parameter value from VB"
    End Sub
 
2. An even more flexible way of passing parameters would be to make use of "Invisible" properties in a Rose model. From your VB program, you can create your own properties Name/Value pairs under the Logical View package (or any other default/existing elements), and then, in turn, have your RoseScript read those properties:
' // in VB program:
    Dim iRose As Object, strParam As String
    On Error Resume Next
    Set iRose = GetObject(, "Rose.Application")
    If iRose Is Nothing Then
        Set iRose = CreateObject("Rose.Application")
    End If
    If Option1.Value = True Then
        iRose.Visible = True
    End If
    'Create a couple of hidden properties for "Logical View" package for my parameters
    Dim pkgLV As Object
    Set pkgLV = iRose.CurrentModel.RootCategory  ' RootCategory is the Logical View package
    strParam = "Test parameter value from VB"
    If Not pkgLV.CreateProperty("myParams", "Param1", strParam, "String") Then
        MsgBox "ERROR: Failed to create Param1"
    End If
    If Not pkgLV.CreateProperty("myParams", "Param2", "Param2 Value", "String") Then
        MsgBox "ERROR: Failed to create Param2"
    End If
    
    iRose.ExecuteScript "C:\Temp\test.ebs"
 
' // and the test.ebs:
    Sub Main
         MsgBox RoseApp.CurrentModel.RootCategory.GetPropertyValue("myParams", "Param1")
         MsgBox RoseApp.CurrentModel.RootCategory.GetPropertyValue("myParams", "Param2")
    End Sub
 
Hope this helps - please let me know via the Service Request you already have open with me.
 
 
Thank you,
 
Shaquille Asghari
Senior Support Engineer
Rational Software Corporation
 
Support: 1-800-433-5444
Sales/Licensing: 1-800-728-1212
 
 
-----Original Message-----
From: Dan Liu [mailto:[EMAIL PROTECTED]]
Sent: Friday, November 22, 2002 10:29 AM
To: 'Kennedy, Patrick'; [EMAIL PROTECTED]
Subject: RE: (ROSE) RoseScript and VB

Patrick,
 
Thanks for the reference.
 
What I need is to pass a parameter from a VB program to a RoseScript, which is called from the VB program.
The reference provided is to pass parameters from command lines.
 
Is there any way to pass commanline information to Rose Applciation, throught CreateObject or CreateObjectInstance in VB?
 
Thanks /dan
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Kennedy, Patrick
Sent: Thursday, November 21, 2002 8:17 PM
To: 'Dan Liu'; [EMAIL PROTECTED]
Subject: RE: (ROSE) RoseScript and VB

Check out the following, might help,

http://solutions.rational.com/solutions/
Solution Id:  9832 
WINDOWS: How to pass parameters to Rational Rose scripts?

Patrick Kennedy
 Rational Support

-----Original Message-----
From: Dan Liu [mailto:[EMAIL PROTECTED]]
Sent: Thursday, November 21, 2002 4:33 PM
To: [EMAIL PROTECTED]
Subject: (ROSE) RoseScript and VB



Hi, all

I am execute a RoseScript file from a VB program, using method call
RoseApp.ExecuteScript   .
Is there any way to pass a parameter from the VB program to the RoseScript,
so the RoseScript can use the parameter while runing.

Appreciate your helps. /dan
************************************************************************
* Rose Forum is a public venue for ideas and discussions.
* For technical support, visit http://www.rational.com/support
*
* Post or Reply to: [EMAIL PROTECTED]
* Subscription Requests: [EMAIL PROTECTED]
* Archive of messages:
*    http://www.rational.com/support/usergroups/rose/rose_forum.jsp
* Other Requests: [EMAIL PROTECTED]
*
* To unsubscribe from the list, please send email
*    To: [EMAIL PROTECTED]
*    Subject: <BLANK>
*    Body: unsubscribe rose_forum
*************************************************************************

Reply via email to