[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [trading] [amibroker] Starting AB with different data bases



PureBytes Links

Trading Reference Links


Careful ... There are line wraps.

--- In amibroker@xxxxxxxxxxxxxxx, "Fred" <ftonetti@xxxx> wrote:
> 
> This should get you there and then some ...
> 
> Put the code in a file in your AmiBroker directory.  It needs to 
> have a filetype of .vbs
> 
> This will check to make sure AB is not running ... start AB 
assuming 
> it's not already running and load the default data base ... If you 
> need a different one loaded then change the constant name.
> 
> Option Explicit
> 
> Dim oWinMgm
> Dim oProcess
> Dim oAB
> Dim oWSH
> Dim oFSO
> 
> Dim iAbIsOpen
> Dim iResult
> Dim iError
> Dim sScriptName
> 
> Const cstDataBaseDir = "C:\Program Files\AmiBroker\Data\"
> 
> sScriptName = "Start AmiBroker"
> 
> Set oWSH  = WScript.CreateObject("WScript.Shell")
> iAbIsOpen = false
> 
> Err.Clear
> 
> Set oWinMgm = GetObject("WinMgmts://localhost")
> 
> If Err <> 0 Then
>     WScript.Echo Err.Description
>     iError = True
> End if
> 
> iResult = oWSH.popup("Checking To See If Amibroker Is Running...", 
> 3, sScriptName, 64)
> 
> For Each oProcess in oWinMgm.ExecQuery ("select * from 
Win32_Process 
> where name='Broker.exe'")
>     iAbIsOpen = true
> Next
> 
> If Err <> 0 Then
>     WScript.Echo Err.Description
>     iError = True
> End if
> 
> If Not iAbIsOpen Then
>     iResult = oWSH.popup("Running Amibroker Now...", 3, 
sScriptName, 
> 64)
>     iResult = oWSH.Run ("Broker.exe", 3, false)
>     WScript.Sleep(1000)
> Else
>     iResult = oWSH.popup("Amibroker Already Running", 3, 
> sScriptName, 64)
> End If
> 
> If Err <> 0 Then
>     WScript.Echo Err.Description
>     iError = True
> End if
> 
> set oWinMgm = Nothing
> 
> If iError then
>     Quit
> End If
> 
> Set oFSO = CreateObject("Scripting.FileSystemObject")
> Set oAB  = CreateObject("Broker.Application")
> 
> iResult = oWSH.popup("Loading Database ...", 3, sScriptName, 64)
> If Not oAB.LoadDatabase(cstr(cstDataBaseDir)) Then
>     MsgBox "Cant Load Database"
>     iError =true
> End





------------------------ Yahoo! Groups Sponsor --------------------~--> 
$4.98 domain names from Yahoo!. Register anything.
http://us.click.yahoo.com/Q7_YsB/neXJAA/yQLSAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/