Dynamically determine the Runtime directory

Hi,

II have configured two systems; the first system has run time folder as swrun.16 and the second system has swrun.17.
I want to install/register some components into the run time folder programatically.
Could you please suggest a way how to dynamically determine the Runtime directory?

Thanks,

Aji Cherian

  • 0  

    Do you have the runtime installed on Linux/UNIX or Windows?

    ---

    Martin Turner

    Senior Technical Support Engineer

    Rocket Software

  • 0 in reply to   

    Currently, we are planning it for runtime installed in Windows, planning to implement this for Linux/Unix later.

  • Suggested Answer

    0   in reply to 

    Unfortunately there are no native ways to do what you ask.

    I'm not sure how you are installing AcuCOBOL on WIndows but you could query the registry for the location of the runtime or set a custom registry entry that you can query.

    On Linux you could parse the LD_LIBRARY_PATH for the path of the runtime in use.

    If you are using a separate runtime config file for each runtime you could also set a variable in the config file that points to the location of the runtime.

    ---

    Martin Turner

    Senior Technical Support Engineer

    Rocket Software

  • 0 in reply to   

    Thanks Martin Turner. We declared an environmental variable in the cblconfi file for the runtime directory. This works, however, when put this on customer system, if the runtime directory is named differently, we need to change the config file. To overcome this, we are searching for dynamic way to find the runtime directory.

  • 0

    If you're using the path of the exe when starting the runtime you could try to get the command line with something like this:

               CALL "KERNEL32.DLL@WINAPI".
               CALL "MSVCRT.DLL".
               CALL "GetCommandLineA"      GIVING WORK-MEMPTR.
               CALL "strcpy"               USING
                                           BY REFERENCE WORK-CMDLINE
                                           BY VALUE WORK-MEMPTR.
               CANCEL "MSVCRT.DLL".
               CANCEL "KERNEL32.DLL@WINAPI".

    This is the bare minimum. But it works for us - even if there are multiple runtimes installed on the device.

    However it doesn't work if you call just the exe and Windows determines the path using the PATH variable.

  • 0 in reply to 

    The "C$CHDIR" function, when called with a blank directory, will return the current directory's name.  Thus you can find what the current directory is.  If you launch the software from within the appropriate directory, this will let you know which one you are in. 

    Alternatively, if you use a full pathname to launch your application, you can use ACCEPT <var> FROM COMMAND-LINE and parse the beginning of the string to get the path used for the runtime.  eg) the var contents might be "/mypath/swrun.16 <options>", so you can find the first space, check the characters in front of it, and there's your indicator.

  • 0 in reply to 

    Apologies.  I haven't used the accept from command-line for ages, and I forgot that it only gets what comes AFTER the program name.  So no runtime path, no runtime arguments etc.   You would have to use the dll method that aw_muench posted.