Home AMX User Forum AMX General Discussion

Question of timelines

Ok, I've tried it a few times and have discovered that I cannot get timelines to work if I use an array variable in their declaration. I was hoping for an explanation of why.

An example:

The following will not work:
Define_Variable (*Or Sometimes Define_Constant, neither works*)

long Proj_Warm_TL[3]  =  {11,12,13}

long Proj_Warm_Times= {60000}

Define_Variable (*Always*)

integer  nProj_Sel

integer Proj_On_Butt[] = {101,103,105}  //Just for the sake of argument

integer nProj_Pwr[3]
integer nProj_Warm[3]

//Fictitious Define_Subroutine Here designation

Define_Call 'Projector On' (integer TWhich_Proj) //VERY Simplified for this exercise
{
   If (! nProj_Pwr[TWhich_Proj] )
   {
      on[nProj_Warm[TWhich_Proj]]
      timeline_create (Proj_Warm_TL[TWhich_Proj], Proj_Warm_Times, 1, timeline_relative, timeline_once)
   }
}

Define_Event

Button_Event [tp,Proj_On_Butt] (*I KNOW I didn't define a TP here....  ASSUME it's a Touch panel that has been defined *)
{
   Push:
   {
      nProj_Sel = Get_last (Proj_on_Butt)
      Call 'Projector On' (nProj_Sel)
   }
}

timeline_event [Proj_Warm_TL[1] (*Or even as 11*) ]
{
   Off [nProj_Warm[1]]
   On [nProj_Pwr[1]]
}
timeline_event [Proj_Warm_TL[2] (*Or even as 12*) ]
{
   Off [nProj_Warm[2]]
   On [nProj_Pwr[2]]
}
timeline_event [Proj_Warm_TL[3] (*Or even as 13*) ]
{
   Off [nProj_Warm[3]]
   On [nProj_Pwr[3]]
}


BUT! This works just Dandy!:
Define_Variable (*Or Sometimes Define_Constant you get it*)

long Proj_Warm_TL1  =  11
long Proj_Warm_TL2  =  12
long Proj_Warm_TL3  =  13

long Proj_Warm_Times= {60000}

Define_Variable (*Always*)

integer  nProj_Sel

integer Proj_On_Butt[] = {101,103,105}  //Just for the sake of argument

integer nProj_Pwr[3]
integer nProj_Warm[3]

//Fictitious Define_Subroutine Here designation

Define_Call 'Projector On' (integer TWhich_Proj) //VERY Simplified for this exercise
{
   If (! nProj_Pwr[TWhich_Proj] )
   {
      on[nProj_Warm[TWhich_Proj]]
      timeline_create ((10+TWhich_Proj), Proj_Warm_Times, 1, timeline_relative, timeline_once)
   }
}

Define_Event

Button_Event [tp,Proj_On_Butt] (*I KNOW I didn't define a TP here....  ASSUME it's a Touch panel that has been defined *)
{
   Push:
   {
      nProj_Sel = Get_last (Proj_on_Butt)
      Call 'Projector On' (nProj_Sel)
   }
}

timeline_event [Proj_Warm_TL1 ]
{
   Off [nProj_Warm[1]]
   On [nProj_Pwr[1]]
}
timeline_event [Proj_Warm_TL2 ]
{
   Off [nProj_Warm[2]]
   On [nProj_Pwr[2]]
}
timeline_event [Proj_Warm_TL3 ]
{
   Off [nProj_Warm[3]]
   On [nProj_Pwr[3]]
}

Ok... Why?

Ignoring all the possible silly typos and stylistic jibber-jabber(I really need a Mr. T emoticon here!!), I don't see why this shouldn't work.

Isn't the value of TL[1] in the first exercise = 11? As a LONG Constant, the same TL1 (or 10+TWhich_Proj) in the second example?

The first example ALWAYS bogs the rest of the code following to a stop..... No more feedback and mostly poor performance. The controller though gives no indication of any problem in diagnostics or telnet messages.

I was just curious for enlightenment purposes.

Thanks in advance for the information.

Comments

  • Joe HebertJoe Hebert Posts: 2,159
    feddx wrote: »
    Ok, I've tried it a few times and have discovered that I cannot get timelines to work if I use an array variable in their declaration. I was hoping for an explanation of why.
    Timeline arrays are not supported at this time as per Tech Note 697.
  • a_riot42a_riot42 Posts: 1,624
    Don't use a variable either or bad stuff will happen. Use a constant.
  • ericmedleyericmedley Posts: 4,177
    yeah, this is one I hope they do modify. Using an array would be very nice.
  • Joe HebertJoe Hebert Posts: 2,159
    ericmedley wrote: »
    yeah, this is one I hope they do modify. Using an array would be very nice.
    I agree, I'd like to use timeline arrays also.
  • ericmedleyericmedley Posts: 4,177
    Joe Hebert wrote: »
    I agree, I'd like to use timeline arrays also.

    howsabout this... :D
    TIMELINE_EVENT[0]
    {
    CALL 'TIME_EVERYTHING'
    }
    
    
  • DHawthorneDHawthorne Posts: 4,584
    ericmedley wrote: »
    howsabout this... :D
    TIMELINE_EVENT[0]
    {
    CALL 'TIME_EVERYTHING'
    }
    
    

    Is that part of the SET_OUTDOOR_TEMPERATURE routine?
  • feddxfeddx Posts: 183
    Thanks!

    Now I know there is a definitive answer. I should check the tech notes more often, but oh well.....

    And I was really looking for more of a timeline like this:
    Define_Constant
    
    long Revert_TL  =  1
    
    slong Revet_Times= {0,-3600000}
    
    Timeline_Create (Revert_TL,Revert_Times,2,Timeline_Relative, Timeline_Once)  //Of course this has to be a relative timeline
    
    .
    .
    .
    //Testing to get the clock to roll back
    
    Timeline_event[Revert_TL]
    {
       Switch (timeline.sequence)
       {
          Case 1:System_Call 'Set Universal Clock'
          Case 2:System_Call 'Relieve Stress'
    }
    

    Ahhhhhh... wouldn't that be nice

    But again, thank you all for replying, my curiosity is assuaged!
Sign In or Register to comment.