Back Midas Rome Roody Rootana
  Midas DAQ System  Not logged in ELOG logo
Entry  12 Jun 2019, Marius Koeppel, Forum, Strange JS array creation 
    Reply  17 Jun 2019, Konstantin Olchanski, Forum, Strange JS array creation 
       Reply  24 Jun 2019, Marius Koeppel, Forum, Strange JS array creation 
          Reply  25 Jun 2019, Konstantin Olchanski, Forum, Strange JS array creation 
Message ID: 1570     Entry time: 25 Jun 2019     In reply to: 1567
Author: Konstantin Olchanski 
Topic: Forum 
Subject: Strange JS array creation 
> --> In the midas back-end I never created an array. I created an INT in the ODB with db_create_key(hDB, 0,
> "Equipment/Switching/Variables/DATA_WRITE", TID_INT). By using modset in javascript and parsing the string
> "/Equipment/Switching/Variables/DATA_WRITE[" + String(i) + "]" I call it like an array and it shows up like an
> array in the ODB.

I think you are good. In ODB, a TID_INT is actually an array of size 1. Writing to an array index automatically
extends the array. I am not sure where this is written down, but this is how most ODB array index access functions
have always worked.

You do have a performance bug with your loop, though, by writing a[1], a[2], a[3], you cause
the array to grow from size 1 to size 2. Then grow it from size 2 to size 3, etc. Of course
this only happens the first time you run the thing. Afterwards, the array has the correct size
and does not need to be grown.

K.O.
ELOG V3.1.4-2e1708b5