Originally Posted by Raccoon

The value that $cid returns is inherited by all aliases, etc, called within an event.

I would presume, without testing, that the $cid returned by a modeless dialog event will be whichever $cid happens to be active. I would further presume that the $cid will represent the dialog's "parent" at the time of the dialog event in question, if the dialog had been assigned a parent (-a switch?), but this is all worth testing for yourself.

Rather than looking up a connection's CID, you can simply request the value via $scon(N).cid on demand.

Ok, thanks for the info and I will carry out tests. I assumed the inheritance due to the single thread in mIRC, but needed it confirmed.

Between asking the question and getting your answer, I've been doing a lot of thinking about this and found something that will probably help me out.

Originally the script was designed for a single connection to a specific server There were a significant number of global variables to hold state information and data relevant to the connection, which changed when the server's IRCd was updated (unreal to inspircd). Alongside that ran a separate script for the other connections that was rather minimalistic.

More and more I found that the small script was calling aliases within the bigger initial script, so I decided to amalgamate the 2 scripts, and it will eventually have a connect manager built into it. Rather than making the global variable count double/triple/... (extremely impractical) I decide to make the jump to Hash Tables - never done that before now.

Each server is given a small shortname (3-5 characters) that is used to access the data for each connection, sometimes with suffixes added to the end of that shortname or in conjunction with a code for an object type - example for idlerpg games (possibility of 2 games on any server): the table uses the shortname code + 'C' + GameNumber for the channel name and shortname code + 'B' + GameNumber for the Bot name, and so on.

It's in that area where things start to get complicated. Turns out that 3 servers I connect to have IRPG channels, all called the same name, and 2 of them share the same Bot name, so ensuring I get the correct cid is important. I still use a global variable holding the channel names which is used with On Join code, and is especially good since $addtok will not enter a duplicate - keeps the data size down and probably faster for the channel name checking
 On *:JOIN:%IRPGChannels: { 

I already pass the shortname on to various aliases so decided to create 2 new tables. One called shortname which has the connection id as the item name and the shortname as the data. The other, ConnId, has this reversed: shortname forms the item name, cid the data.

This allows any section of code to look up one or the other dependant upon the info it can get. If it uses the cid it can get the shortname etc. this also removes the need for those multiple if ($server == <whatever>) and makes the whole thing rather dynamic.

The tables are populated as each server is connected using On Logon, and the relevent data removed at On Disconnect. These tables also provide me with the chance to check if a sever is connected or inactive, the inactive one(s) having features in the dialogs disabled if inactive.

It all appears to work at this point, but testing and refining continues.