Home AMX User Forum AMX Technical Discussion

You can't dynamically name Waits?

I'm trying to do something like this:
data_event [devArray] //more than one device can trigger this data_event
i = data.device.port
//i guess i might have to turn i from an int to a char here
WAIT 50 "'myWaits-',i"
{
  do thangs
}

Do I need to make some elaborate If logic that says
If data.device.port = 1
wait 50 'myWaits-1'
etc...

Comments

  • ericmedleyericmedley Posts: 4,177
    That's the case pretty much. I'm not exactly sure what you're trying to accomplish, but it might be easier to use a set of timelines instead.

    It'd be a little easier to grab the port infor as you suggested and just line them up sequentially with your timelines.

    If you're only trying to do a few things that only have to happen once, then the wait might be the best way to go.
  • mpullinmpullin Posts: 949
    Unfortunately, waits are created at compile time, not run time; each wait you type in your program has a unique address and can't be called while a previous instance of that wait is still running. You have to type a constant string and constant number.
  • DHawthorneDHawthorne Posts: 4,584
    mpullin wrote: »
    Unfortunately, waits are created at compile time, not run time; each wait you type in your program has a unique address and can't be called while a previous instance of that wait is still running. You have to type a constant string and constant number.

    Yes, and because they are created at compile time, using a variable to name one means the compiler has no idea how many to create since the variable could change. Creating an infinite number of any kind of resource is bound to crash something somewhere :).

    It's a shame all NetLinx dynamic allocation is "under the hood." This is one of those cases where being able to call a constructor would be handy.
Sign In or Register to comment.