I will look into the version you uploaded and report back, though it may take a while as I am currently under Windows to do some maintenance.
Alexey wrote:>Enable communication between **separate** first instances and their respective **second** instances. This is a slightly tricky concept
hmm, I don't like that idea- I dont know IPC codde at all (I just use ready wrapper) and it sounds tricky.

noone will need it..
Well, I for one need it: as I wrote, I have patched every single editor (if I had the source code in a language I could readily work with

) to implement exactly this feature.
In general... it is IMHO almost always an error for developers to assume they know what is best for their users or what will be used (and how it will be used) or won't be used. This brings us software like MS Windows or the GTK stuff. Secondly, I don't think that this issue does need an immediate resolution. I'd rather have something that is well designed and well-thought through than a quick fix.
As to the IPC bit itself... a first instance registers itself as
the first instance by creating an IPC server using a unique id string (Cud uses the hardcoded 'cudatext.0' as a unique id) and waiting for second instances to query that unique id. In other words, the definition of a first instance is exactly that it uses an id string that has as yet not been registered by another instance.
Any freshly started instance looks for a previous instance with their own id string and if they can't find a running IPC server instance with this id string then they are the first instance. If they can find it, they have found their corresponding first instance and simply send their data over to their first instance.
Going back to my earlier example:
1. Start a cudatext first instance with an id of "cudatext.1" by running "cudatext -id=cudatext.1 file1a.txt". This registers an IPC server with id 'cudatext.1' which waits for second instances.
2. Start another cudatext first instance with an id of "cudatext.2" by running "cudatext -id=cudatext.2 file2a.txt". This registers another IPC server with id 'cudatext.2' which waits for second instances.
3. Start a third cudatext instance by running "cudatext -id=cudatext.1 file1b.txt". This instance looks for an IPC server with id 'cudatext.1', finds it and sends its parameters over. The first instance receives those parameters and does its job. The third instance terminates.
4. Start another third cudatext instance by running "cudatext -id=cudatext.2 file2b.txt". This instance looks for an IPC server with id 'cudatext.2', finds it and sends its parameters over. The first instance receives those parameters and does its job. The third instance terminates.
Pseudo code (based on your changed formmain.pas, see procedure InitUniqueInstanceObject):
uniqIdString=GetIdstringFromParamStrArray(...); // get unique idstring from -id=blabla command line option
AppUniqInst.Identifier:= uniqIdString;
Try it... either it works

or it doesn't

. Whatever it does, I don't think your PC will go up in flames
And I do appreciate that you're looking into this
