Title: RE: (ROSE) RoseScript and VB
Well no option for parameters per online help,
 
- - - - - - - - - - - - - - - - - - -
ExecuteScript Method (Application)
 
Syntax
 
theApplication.ExecuteScript theFileName
 
Syntax
 
theApplication.ExecuteScript theFileName
 
Element Description
 
theApplication As Application  
Instance of the Rational Rose application in which the script is being executed
 
theFileName As String 
Name of the file that contains the script to execute
- - - - - - - - - - - - - - - - - - -
 
I tried to play around with the code snippets below to
see if I could somehow get the arguments, but no go.
 
Unfortunately I don't of anyway to directly pass a parameter
here.  The only Kludge that comes to mind, is to create
a text file with value in vb, read in rosescript.
 
Might be a better idea, but I don't know of it.
 

- VB test program ---------------------
 
Private Sub Form_Load()
 Dim aClass As Object
   Dim allClasses As Object
   Dim roseApp As Object
 
   On Error Resume Next
   Set roseApp = GetObject(, "Rose.Application")
   If roseApp Is Nothing Then
      Set roseApp = CreateObject("Rose.Application")
   End If
   'When you call GetRoseApplication the first time, the value
   'of roseApp will be Nothing and GetObject will be
   'attempted.  If GetObject fails, then a new instance is
   'created using CreateObject. From that point on you will be
   'using the same instance of Rose's automation server.
   'If you relied on GetObject, your program would break if the
   'user opened another instance of Rose.
   
    roseApp.Visible = True
    'theApplication.ExecuteScript theFileName
    scriptname = "e:\t4\test.ebx"
    roseApp.ExecuteScript scriptname
    MsgBox ("DONE")
End Sub
 
-test.ebx----------------------------
Sub Main
 
    ' If you call rose with:
    ' rose "arg1 arg2 arg3" myscript.ebx
    ' then Rose will be called with the execution of the ebx
    ' file and the string of args will be accessible from
    ' roseapp.commandline
 
    ' output from above example:
    ' Command line string: arg1 arg2 arg3
    ' Argument 1: arg1
    ' Argument 2: arg2
    ' Argument 3: arg3
 
    ' Code taken from MS technote and modified slighty for Rose
    ' DOCUMENT:Q126939
    ' TITLE   :How To Parse a Delimited String Using InStr And Mid
 
      viewport.open
      viewport.clear
 
      Dim DataString As String
      Redim SubStr(0) As String
      Dim SubStrCount As Integer
      Dim i As Integer
 
      ' store arguments to string:
      DataString = roseapp.commandline
      ' workaround for defect in rose
      ' "arg1 arg2 arg3" returns
      ' "arg1 arg2 arg3
      ' i.e. leading " retained
      x = Len(DataString)-1
      DataString = Right$(DataString,x)
 
      Print "Command line string: " & DataString
 
      ' Parse the string into sub-strings:
      SubStrCount = ParseString(SubStr(), DataString, " ")
 
      ' Display the sub-strings:
      For i = 1 to SubStrCount
         Print "Argument " & i & ": " & SubStr(i)
      Next
 
End Sub
 
Function ParseString (SubStrs() As String, SrcStr As String, Delimiter As
String) As Integer
 
      ' Dimension variables:
      ReDim SubStrs(0) As String
      Dim CurPos As Long
      Dim NextPos As Long
      Dim DelLen As Integer
      Dim nCount As Integer
      Dim TStr As String
 
      ' Add delimiters to start and end of string to make loop simpler:
      SrcStr = Delimiter & SrcStr & Delimiter
      ' Calculate the delimiter length only once:
      DelLen = Len(Delimiter)
      ' Initialize the count and position:
      nCount = 0
      CurPos = 1
      NextPos = InStr(CurPos + DelLen, SrcStr, Delimiter)
 
      ' Loop searching for delimiters:
      Do Until NextPos = 0
         ' Extract a sub-string:
         TStr = Mid$(SrcStr, CurPos + DelLen, NextPos - CurPos - DelLen)
         ' Increment the sub string counter:
         nCount = nCount + 1
         ' Add room for the new sub-string in the array:
         ReDim Preserve SubStrs(nCount) As String
         ' Put the sub-string in the array:
         SubStrs(nCount) = TStr
         ' Position to the last found delimiter:
         CurPos = NextPos
         ' Find the next delimiter:
         NextPos = InStr(CurPos + DelLen, SrcStr, Delimiter)
      Loop
 
      ' Return the number of sub-strings found:
      ParseString = nCount
 
End Function
Patrick Kennedy
 Rational Support
 
 
-----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