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

Re: [amibroker] Re: Endless loop detected in FOR loop



PureBytes Links

Trading Reference Links

Hi Fred,
here's an example. This was tested in "Explore".
The table handle 'th' was used in this example.
UM

    //-----------------------------------------------------------------  
    // HOW TO FILL AN AFL ARRAY WITH VALUES FROM A TABLE:

    // define the array which you would like to use
    // this sets up an "array" by a copy of the "C" array
    myArray = C;

    // initialize all elements of myArray to 0  (or use -1e10 for "null" data)
    for (i = 0; i < BarCount; i++)
      myArray[i] = 0;

    // all arrrays in AFL have a fixed number of elements (BarCount)
    // so we may fill only that much elements!

    // calculate how much maximally can be retrieved 
    // from the table AND filled in the array
    nMax = TableGetRowCount(th);
    if (nMax > BarCount)
      nMax = BarCount;

    // finally fill the array from table1's column0 cells
    for (i = 0; i < nMax; i++)
      {
        myArray[i] = TableDataGet(i, 0, th);   // col 0 was defined as of type float
        //...
      }

    // the first nMax elements of myArray were filled from the table
    // for simplicity we are displaying the last index filled and its value
    // in the results tab:
    AddColumn(nMax - 1,          "lastFilledElemIndex", 1.0);          // remember ZERO based...
    AddColumn(myArray[nMax - 1], "lastFilledElemValue", 1.3);   
    //... 

    //-----------------------------------------------------------------  


----- Original Message ----- 
From: "Fred" <fctonetti@xxxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Wednesday, May 07, 2003 10:21 AM
Subject: [amibroker] Re: Endless loop detected in FOR loop


> Tomasz,
> 
> Yes I'm sure it's not endless.  If I slowly build up the number of 
> things that the loop is doing it shuts down just about at the number 
> you quoted.
> 
> ANOTHER QUESTION THOUGH ... How do I store a variable in a particular 
> occurance of an array.  I'm wanting to unload a column from one of 
> the tables in ABTool which I assumed I needed a loop to get at it, 
> but no matter how I code it I get syntax errors.
> 
> Example:
> 
> for (i = 0, i < BarCount, i++)
> {
>     Array[i] = Table-Value(i, 0, th1);
> }
> 
> If I code it with a single = I get a type mismatch.  If I code it 
> with a double == I get operation not allowed.
> 
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" <amibroker@xxxx> 
> wrote:
> > Fred,
> > 
> > I will add a "turn-off" check box in next beta.
> > By the way: single loop must have at least 100'000
> > iterations AND more than 2 * number of bars for
> > this to appear. Are you sure that your loop is not endless?
> > 
> > In the mean time you may rewrite your code from
> > 
> > for( i = 0; i < 1000000; i++ )  // causes endless loop detection to 
> activate
> > {
> >   // do something with
> >   // array[ i ]
> > }
> > 
> > to 2 nested loops:
> > 
> > for( i = 0; i < 1000000; i = i + 10 ) // does not activate endless 
> loop detection
> >   for( k = 0; k < 10; k++ )
> >   {
> >     // do something with
> >     // array[ i + k ]
> >   }
> > 
> > 
> > the net effect is the same: you can iterate array million times 
> from 0
> > upto 999999 but 'endless loop detection' does not activate.
> > 
> >   
> >  
> > Best regards,
> > Tomasz Janeczko
> > amibroker.com
> > ----- Original Message ----- 
> > From: "Fred" <fctonetti@xxxx>
> > To: <amibroker@xxxxxxxxxxxxxxx>
> > Sent: Wednesday, May 07, 2003 6:56 AM
> > Subject: [amibroker] Re: Endless loop detected in FOR loop
> > 
> > 
> > > Bob,
> > > 
> > > That doesn't seem to do the trick ... or maybe I just haven't 
> > > implemented it in the right way.  Can you supply a line of code 
> that 
> > > you'd use to do this and the context in which you'd do it.  I've 
> > > tried AlertIf and some others, none of which get around the 
> problem.
> > > 
> > > Fred
> > > 
> > > --- In amibroker@xxxxxxxxxxxxxxx, "Bob Jagow" <bjagow@xxxx> wrote:
> > > > Display something from within the loop.
> > > > Perhaps cout << "Don't turn me off"?
> > > > 
> > > > -----Original Message-----
> > > > From: Fred [mailto:fctonetti@x...]
> > > > Sent: Tuesday, May 06, 2003 3:21 PM
> > > > To: amibroker@xxxxxxxxxxxxxxx
> > > > Subject: [amibroker] Endless loop detected in FOR loop
> > > > 
> > > > 
> > > > Tomasz,
> > > > 
> > > > With some of the processor intensive table handling of ABTool 
> it 
> > > > would be very helpful to have a less sensitive routine for ... 
> > > > 
> > > > Endless loop detected in FOR loop
> > > > 
> > > > Either that or could you provide some guidance as to what could 
> be 
> > > > done by users to keep this message from being displayed and the 
> > > > related processing grinding to a halt.
> > > > 
> > > > Thanks in advance, Fred
> > > > 
> > > > --- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" 
> > > <amibroker@xxxx> 
> > > > wrote:
> > > > > Hello,
> > > > > 
> > > > > The link is actually:
> > > > > http://www.amibroker.net/3rdparty/TimeFrame.dll
> > > > > 
> > > > > (I guess I should get some sleep because I am making too many 
> > > > mistakes)
> > > > > 
> > > > > Best regards,
> > > > > Tomasz Janeczko
> > > > > amibroker.com
> > > > > ----- Original Message ----- 
> > > > > From: "Tomasz Janeczko" <amibroker@xxxx>
> > > > > To: <amibroker@xxxxxxxxxxxxxxx>
> > > > > Sent: Tuesday, May 06, 2003 11:37 PM
> > > > > Subject: Re: [amibroker] Warning: TimeFrame DLL causes 
> problems 
> > > > with scripting
> > > > > 
> > > > > 
> > > > > > Hello,
> > > > > > 
> > > > > > Actually my previous message had an error.
> > > > > > Only the documentation 
> > > > (http://www.amibroker.net/3rdparty/TimeFrame.PDF
> > > > > > is OLD and states that afL function is included, 
> > > > > > but the plugin itself is new and there is no afL function 
> > > inside.
> > > > > > 
> > > > > > The TimeFrame.dll present on the site is updated
> > > > > > and has afL function renamed to TmL.
> > > > > > So it should not cause problems any more.
> > > > > > 
> > > > > > So if you are using old TimeFrame.dll plugin you should
> > > > > > get the update 
> > > > > > http://www.amibroker.com/3rdparty/TimeFrame.dll
> > > > > > 
> > > > > > 
> > > > > > Best regards,
> > > > > > Tomasz Janeczko
> > > > > > amibroker.com
> > > > > > ----- Original Message ----- 
> > > > > > From: "Tomasz Janeczko" <tj@xxxx>
> > > > > > To: <amibroker@xxxxxxxxxxxxxxx>
> > > > > > Sent: Tuesday, May 06, 2003 11:31 PM
> > > > > > Subject: [amibroker] Warning: TimeFrame DLL causes problems 
> > > with 
> > > > scripting
> > > > > > 
> > > > > > 
> > > > > > > Hello,
> > > > > > > 
> > > > > > > Unfortunatelly the TimeFrame.dll available
> > > > > > > from http://www.amibroker.net/3rdparty.php
> > > > > > > is OLD and includes old afL() function that caused so
> > > > > > > many problems in the past.
> > > > > > > http://groups.yahoo.com/group/amibroker/message/27288
> > > > > > > 
> > > > > > > It is strange because Stephane was supposed to fix
> > > > > > > this months ago.
> > > > > > > 
> > > > > > > Best regards,
> > > > > > > Tomasz Janeczko
> > > > > > > amibroker.com



------------------------ Yahoo! Groups Sponsor ---------------------~-->
Rent DVDs Online - Over 14,500 titles.
No Late Fees & Free Shipping.
Try Netflix for FREE!
http://us.click.yahoo.com/YoVfrB/XP.FAA/uetFAA/GHeqlB/TM
---------------------------------------------------------------------~->

Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 

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