Book a Demo

Author Topic: who run script in DOS console  (Read 5322 times)

Cisore

  • EA User
  • **
  • Posts: 67
  • Karma: +0/-0
    • View Profile
who run script in DOS console
« on: May 31, 2012, 09:13:34 pm »
Hello,

I have see VBScript in EA and I would like to know if this possible to run this in DOS console ? And how ?

(The goal is to run script with .bat file)

thank for answers.

Cisore

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: who run script in DOS console
« Reply #1 on: May 31, 2012, 11:03:29 pm »
Sure you can write a bat that invokes a VB script dealing with a repository.

q.

Cisore

  • EA User
  • **
  • Posts: 67
  • Karma: +0/-0
    • View Profile
Re: who run script in DOS console
« Reply #2 on: June 01, 2012, 12:15:29 am »
Of course. But how can I do the like between the VB Script and the EA's project ?

(For example : if I want to run the VBScript - Manage Packages Example, one of the EA's example script - what command I need to do ?)  

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: who run script in DOS console
« Reply #3 on: June 01, 2012, 01:59:55 am »
Well, RTFM about EA's API. To get familiar there are a couple of scripts in the internal script editor you can start to accommodate with. Later you can bind to the EA application from VB (via GetObject?! don't remember the right call) to access a repository.

q.

Cisore

  • EA User
  • **
  • Posts: 67
  • Karma: +0/-0
    • View Profile
Re: who run script in DOS console
« Reply #4 on: June 01, 2012, 06:54:22 pm »
what is "RTFM" ?

I have already seen the examples.
But I don't see how run this in DOS console

Cisore

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: who run script in DOS console
« Reply #5 on: June 01, 2012, 08:27:14 pm »
Quote
what is "RTFM" ?
http://bit.ly/telEk5 ;)

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: who run script in DOS console
« Reply #6 on: June 01, 2012, 08:39:35 pm »
I can't recall the VB syntax but in Perl I use
Code: [Select]
Win32::OLE->GetActiveObject ("EA.App")
to retrieve the active EA instance. There's a similar system API call to create a new instance where you then need to call
Code: [Select]
Repository.OpenFile (filenam)
q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: who run script in DOS console
« Reply #7 on: June 01, 2012, 09:00:36 pm »
This is what I use in VB(A)
Code: [Select]
'-------------------------------------------------------------
' Author:   Geert Bellekens
' Date:     17/12/2007
' Description: Return the currently opened EA Model
'-------------------------------------------------------------
Public Function getCurrentRepository() As EA.repository
    Dim EAapp As EA.App
    Dim EArepository As EA.repository
    Set EAapp = GetObject(, "EA.App")
    'Warning when EA not open
    If EAapp Is Nothing Then
        MsgBox "Please Open Enterprise Architect"
        'try again
        Set getCurrentRepository = Me.getCurrentRepository
    End If
    'Warning when no repository is opened.
    Set EArepository = EAapp.repository
    If EArepository Is Nothing Then
        MsgBox "Please open a Model in Enterprise Architect"
        'try again
        Set getCurrentRepository = Me.getCurrentRepository
    End If
    'return the found repository
    Set getCurrentRepository = EAapp.repository
End Function

Geert

Cisore

  • EA User
  • **
  • Posts: 67
  • Karma: +0/-0
    • View Profile
Re: who run script in DOS console
« Reply #8 on: June 01, 2012, 10:12:49 pm »
I have take your code
I put it in a new file (test.vbs)
And I try to run this in DOS console (test.vbs)

But I have a error :
Line 3 / char 22 / Expected end of statement

I think they missing declaration of "package" EA.

What can I do ?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: who run script in DOS console
« Reply #9 on: June 01, 2012, 10:40:05 pm »
I think you somehow have to tell your it to use the EA library.
In VBA or .Net you have to add a reference to the EA COM/Interop.

But I don't know how you need to to that in vbscript.

Geert

Cisore

  • EA User
  • **
  • Posts: 67
  • Karma: +0/-0
    • View Profile
Re: who run script in DOS console
« Reply #10 on: June 04, 2012, 08:23:54 pm »
Quote
I think you somehow have to tell your it to use the EA library.
In VBA or .Net you have to add a reference to the EA COM/Interop.

Geert

How do you do in VBA ?

Think

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: who run script in DOS console
« Reply #11 on: June 04, 2012, 08:32:17 pm »
Via Tools|References and then select Enterprise Architect Object Model

Geert