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

[amibroker] Re: VBScript within AFL Function ?



PureBytes Links

Trading Reference Links

Excellent ... Thanks ...

--- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" <groups@xxx> 
wrote:
>
> Hello,
> 
> You put VBScript code parts directly inside AFL function because
> VBScript code snipplets are executed directly and immediatelly at 
the place
> where they are defined.
> 
> What you can do is to
> write VBScript function that is callable from AFL level (using 
GetScript object),
> so to have what you want you may:
> a) write VBScript function
> b) inside AFL function use GetScriptObject and call VBScript 
method from there
> The net result would be the same i.e. executing VBScript code 
parts by calling AFL function.
> 
> Example how to do that is here:
> http://www.amibroker.com/guide/a_aflcom.html
> 
> I have modified your code to show you how this should be done 
correctly.
> 
> EnableScript("VBScript"); 
> 
> <% 
> function TestVB() 
>         RRR = AFL.Var("YYY") 
>         SSS = 7 
> 
>         MsgBox CStr(RRR) + " " + CStr(SSS) 
> 
>         AFL.Var("TTT") = RRR 
>         AFL.Var("UUU") = SSS 
>         TestVB = 0   
> End function 
> %> 
> 
> function XXX(YYY) 
> { 
>     ZZZ = 0; 
> 
>     printf(NumToStr(YYY) + "\n"); 
> 
>     scr = GetScriptObject(); 
>     scr.TestVB(); 
> 
>     printf(NumToStr(TTT) + "\n"); 
>     printf(NumToStr(UUU) + "\n"); 
> 
>     ZZZ = 0; 
> 
>     return; 
> } 
> 
> XXX(6); 
> 
> 
> BUT... there is one big caveat:
> displaying MsgBox from VBscript side it is highly discouraged 
because
> it stops execution and will hang AB until message box is dismissed.
> 
> For UI elements you should use Param() functions instead. For 
tracing output
> you should use _TRACE instead.
> 
> 
> 
> Best regards,
> Tomasz Janeczko
> amibroker.com
> ----- Original Message ----- 
> From: "Grover Yowell" <gyowell@xxx>
> To: <amibroker@xxxxxxxxxxxxxxx>
> Sent: Tuesday, October 03, 2006 6:02 AM
> Subject: RE: [amibroker] VBScript within AFL Function ?
> 
> 
> > Fred,
> > I've just started to look at vbscript, but I tried your program 
and found
> > the same results as you.  Also, I noted that when I inserted 
your program as
> > an indicator, or in AA, it caused the main chart to disappear 
and a program
> > execution error.
> > 
> > At that point I simplified your program and tried the following 
with the
> > same result:
> > EnableScript("VBScript");
> > y=6;
> > printf(NumToStr(y) + "\n");
> > <%
> >       R = AFL.Var("y")
> >  MsgBox CStr(R)
> > AFL.Var("t")=R+1
> > %>
> > printf(NumToStr(t) + " end\n");
> > 
> > Again, the MsgBox popped up with the correct result but program 
execution
> > halted and the main chart disappeared.
> > 
> > 
> > At that point, I eliminated the MsgBox line and everything 
worked.  So I
> > think the problem in the MsgBox statement.  Don't have a clue on 
what is
> > causing the problem.  I am running Windows XP Pro.  I have also 
tried to run
> > the Jscript for export image within AFL and found a similar 
problem of
> > execution halting.
> > 
> > Hope this helps.
> > 
> > Grover
> > 
> > -----Original Message-----
> > From: amibroker@xxxxxxxxxxxxxxx 
[mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf
> > Of Fred
> > Sent: Monday, October 02, 2006 17:40
> > To: amibroker@xxxxxxxxxxxxxxx
> > Subject: [amibroker] VBScript within AFL Function ?
> > 
> > Anyone have a clue why this apparently doesn't work ?
> > 
> > RRR apparently never gets the value of what is in YYY and thus 
never 
> > returns it to TTT. The MsgBox also shows RRR to be non existant. 
> > There are however no problems with SSS which is set in VBS.  It 
shows 
> > in the message box and via printf.
> > 
> > EnableScript("VBScript");
> > 
> > function XXX(YYY)
> > {
> >    ZZZ = 0;
> > 
> >    printf(NumToStr(YYY) + "\n");
> > 
> >    <%
> >        RRR = AFL.Var("YYY") 
> >        SSS = 7
> > 
> >        MsgBox CStr(RRR) + " " + CStr(SSS)
> > 
> >        AFL.Var("TTT") = RRR
> >        AFL.Var("UUU") = SSS
> >    %>
> > 
> >    printf(NumToStr(TTT) + "\n");
> >    printf(NumToStr(UUU) + "\n");
> > 
> >    ZZZ = 0;
> > 
> >    return;
> > }
> > 
> > XXX(6);
> > 
> > 
> > 
> > 
> > 
> > Please note that this group is for discussion between users only.
> > 
> > To get support from AmiBroker please send an e-mail directly to 
> > SUPPORT {at} amibroker.com
> > 
> > For other support material please check also:
> > http://www.amibroker.com/support.html
> > 
> > 
> > Yahoo! Groups Links
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > Please note that this group is for discussion between users only.
> > 
> > To get support from AmiBroker please send an e-mail directly to 
> > SUPPORT {at} amibroker.com
> > 
> > For other support material please check also:
> > http://www.amibroker.com/support.html
> > 
> > 
> > Yahoo! Groups Links
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> >
>