Go Back

How Do I Retrieve the Name of the DBR Being Ran?

Hi,

Assume the following scenario:

* A DBR Program called MyProgram.dbr
* The Main method is MyCoolProgram

The program is executed like so: dbr.exe exe:MyProgram

I need to retrieve "MyProgram".

JBNAM looked promising (http://docs.synergyde.com/lrm/lrmChap9JBNAM.html) However under Windows this does not give me what I want (because there is no requirement that the Main and the DBR output name be 1:1). Previously we were doing a fair amount of parsing, however with Traditional Synergy in Visual Studio and debugging our parsing logic breaks down. We're looking for "The Synergex Way" to do this rather than rolling our own.

Thank you,
Ace Olszowka

 

4 Answers
0   | Posted by Ace Olszowka to Synergy DBL on 1/26/2017, 7:35 PM
Jerry Fawcett
Would the CMDLN subroutine work for you?  It returns the entire command line that started your Synergy program. 
 

1/26/2017, 8:48 PM   0  
Bill Hawkins
You can use xcall modname().  Just keep iterating through the modules until you get an entry prefixed by "MAIN$", and the rest of the module name is your program name.

1/26/2017, 9:27 PM   0  
Ace Olszowka

Hi Guys,

 

Thank you for your quick responses! Let me try to respond to each (I had responded immediately then my response was eaten by the Resource Center because it timed out then I didn?t feel like rewriting everything):


Bill,

We had debated using this modname() trick, however the end result is the same as JBNAM in that it returns the name of the main method (we have issues where we have numbers at the first part of the dbr name which means we can't use it as the name of the main method).

 

Jerry,

Our current solution uses CMDLN however the complexity involved in the parsing of this command line broke our original implementation. I argue that it was broken from the beginning as it did not support all possible valid permutations to DBR/DBS (this only uncovered itself when the full path to the DBR was passed instead of using Logicals and the "Naked" remote debugger port switch), but that is neither here nor there, the lesson is more comprehensive test cases are needed.

 

While we can fix it we're looking for something built into the base class library, if this had been C# this most likely would have been the correct API to use:

 

    https://msdn.microsoft.com/en-us/library/system.appdomain.friendlyname.aspx

        This is only if you're not doing something exotic where you're spinning up your own app domains within the same executable in which case the correct solution would be:

    https://msdn.microsoft.com/en-us/library/system.diagnostics.process.processname.aspx

 

Basically we need DBL Equivalents to the above.

 

But Ace why can't we p/invoke these? I do not believe p/invoke will return what I want, beyond the performance penalty of spinning up the .NET Framework, ProcessName is most likely going to return dbr.exe/dbs.exe which is not what we need.

 

 

Long story short we went down the path of correcting our parser code we wrote; but it?d be really slick to utilize something built into the API and delete a bunch of our code and have it "just work" the next time.


2/6/2017, 3:48 PM   0  
Mark Vinten
Whilst the process being run is the DBR.EXE it will have command line parameters that tell it what DBR to actually run.  This may only be true for the very first DBR that is run, so if you ever chained to another I'm not sure what would happen there (ie, I'm not sure if it would spawn another DBR process).

I'm pretty sure that you don't need to use .NET to p/invoke from traditional synergy, but it's nowhere near as easy :)
http://docs.synergyde.com/lrm/lrmChap22Introductiontothecinterface.html#Xlay89481
 

2/24/2017, 8:42 AM   0  
Please log in to comment or answer this question.