Martin -

I thought I'd answer this - it avoids taking down Christmas lights and
it offers an opportunity to mention something that I hope TJ catches.

In ths ExportImage case, I'd hope that it is just a bug and is meant 
to be possible within an indicator, since it seems a natural
ParamTrigger application.  Anyway, I'll offer a workaround after 
suggesting an AB addition.

This pattern of passing variables into and out of Amibroker arises in
several different applications.  For example, you may want to run an
AFL with overriden parameters, or invoke a number of different AB
functions outside of AB with parameters.  In your case, you want
invoke a script for ExportImage with a name parameter.

What I really wish that AB had was COM methods for the
following.  It would make MANY THINGS much easier !  I'm hoping that
it would be a straightforward addition to the object model -
     StaticVarSet
     StaticVarGet
     StaticVarSetText
     StaticVarGetText

Anyway, working around it is straightforward.  The general case is
that you want to invoke some script - let's say within an indicator. 
I had a similar one in VBS handy, so let's call this example 
ExportImage.vbs.  First the AFL for the indicator -

trig            = ParamTrigger( "Export image", "CLICK" );
if ( trig )
{
        imgname = "ExportImage1.png";

        OWSHShell       = CreateObject( "WScript.Shell" );
        Cmdline = "ExportImage.vbs " + " \"" + imgname + "\" " + 1024 + " " +
768;
        //  For other options see -
        //       msdn.microsoft.com/en-us/library/d5fk67ky(VS.85).aspx
        rc                      = OWSHShell.Run( Cmdline, 4, False );
}
Plot( C, "C", colorDefault );


Now, the VB script is placed in this case in the \Program Files\Amibroker
directory and looks like this -

Set oWSH        = CreateObject( "WScript.Shell" )
Set oARGS       = WScript.Arguments
imgname         = oARGS( 0 )
width           = oARGS( 1 )
height          = oARGS( 2 )
Set oAB         = CreateObject( "Broker.Application" )
Set OAW         = oAB.ActiveWindow
rc              = OAW.ExportImage( imgname, width, height )

-- Bruce R

--- In [email protected], "grizzly_cz" <grizzly...@...> wrote:
>
> Greetings,
> 
> I am trying to export images from Amibroker via ExportImage. Calling
> directly from Amibroker does not work, also I have read some posts
> that it should be run externally, so I created simple file
> "screenshot.js" in my filesystem which looks like this:
> 
> AB = new ActiveXObject("Broker.Application"); // create Amibroker object
> dir = "C:\\Images\\";
> AB.ActiveWindow.ExportImage( dir+AB.ActiveDocument.Name+".gif", 1680,
> 1050 ); // export image
> 
> 
> This works fine, after execution of this file the image is saved on
disk.
> But I would like to use some static variables saved in Amibroker in my
> javascript file to choose more compound filename. Object "AFL", which
> is used in Amibroker environment, is unknown to scripting host. :o(
> 
> Or maybe it is somehow possible to create an afl formula which could
> call ExportImage with passing chosen filename in variable? Is there a
> way to call screenshot.js with some parameters directly from Amibroker
> formula? Or is it possible to create and call a DLL? Unfortunately, I
> am not able to figure how to use DLLs in Amibroker, so I would be
> grateful even for any URL with basic information about this area.
> 
> 
> Thank you very much,
> Martin
>


Reply via email to