PDA

View Full Version : Table questions


Dan Ullman
03-06-2007, 07:24 PM
Table 1

install_service_table={NMEA_Combiner="ECC NMEA Combiner", GLOBE_Server = "ECC-GLOBE Server", NMEA_logger="ECC NMEA Logger", Log_server = "ECC Log Server", Service_Monitor = "ECC Service Monitor"};

for pack_name,Serv_name in install_service_table do
result = Dialog.Message("Notice", "Service Name"..Serv_name, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
end

When this runs the table elements are in this order in the dialog:

ECC Log Server
ECC-GLOBE Server
ECC Service Monitor
ECC NMEA Logger
ECC NMEA Combiner

I am not sure what controls the sort order. It isn't alphabetical nor is it in order of when they were added.

Table 2

install_service_table={"ECC NMEA Combiner","ECC-GLOBE Server","ECC NMEA Logger","ECC Log Server","ECC Service Monitor"};

for pack_name,Serv_name in install_service_table do
result = Dialog.Message("Notice", "Service Name"..Serv_name, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
end


When this runs the table elements are in this order in the dialog:

ECC NMEA Combiner
ECC-GLOBE Server
ECC NMEA Logger
ECC Log Server
ECC Service Monitor

Which is the order they were added to the table. Each is loaded by its array position.

My question is what controls the order in Table 1?

JXBURNS
03-07-2007, 10:24 AM
Dan,

I came across this the other day when I was trying to use arrays for similar purpose.

From the Help File (Tables (Arrays))

Whoa there—why aren’t the table elements in order? The reason for this is that internally the scripting engine doesn’t store tables as arrays, but in a super-efficient structure known as a hash table. (Don’t worry, I get confused about hash tables too.) The important thing to know is that when you define table elements, they are not necessarily stored in the order that you define or add them, unless you use a numeric array (i.e. a table indexed with numbers from 1 to whatever).

I suspect this may be the same you are seeing.

Rgds John

Dan Ullman
03-07-2007, 11:18 AM
Dan,

I came across this the other day when I was trying to use arrays for similar purpose.

From the Help File (Tables (Arrays))



I suspect this may be the same you are seeing.

Rgds John

Thanks John.

I saw that also. My question is how are these ordered in table one. It isn't random. The table one list is always the same in this configureation.