automatic project loading

automatic project loading

3
NewbieNewbie
3

    Aug 17, 2009#1

    Hi all,
    I am a new user trying to migrate from MultiEdit.
    MultiEdit has a nice feature which I am trying to replicate with some script.
    When starting from command line from a specific directory, ME automatically loads the session associated to that directory/project and if there is not any, it creates a new one.

    With UE I currently made a batch file which loads the ue.prj file in the current directory, but this does not create an empty project if the ue.prj file is not there.

    I wish to create a script automatically called by the batch which performs these steps:
    - if ue.prj is not present it creates a default empty project (it's an ASCII file so it's easy)
    - if it is present it opens it
    - changes UE current directory to the command shell current directory

    The first two steps can be performed also by an external simple application, but the third not. To be clean I am trying to create a unique script which does all these steps.

    I am stuck on the following points:
    - how can I know the current directory from a Script?
    - how can I change the current directory of UE? I mean when I press Open... I would like to see the explorer box starting from the path I have launched UE.

    Anyone has some ideas?

    Another question (I think there is already the answer in this forum, but I can't find), how can I know the filename and directory of an opened file? I see there is isExt and isName in the document object, but can't see something like getName(), ...

    Thanks in advance to everybody.
    Giorgio

    6,683583
    Grand MasterGrand Master
    6,683583

      Aug 18, 2009#2

      Which directory is the current working directory is specified by the options you select at Advanced - Configuration - File Handling - Load. See help about this configuration dialog and use forum search to find more articles about working directory for file open.

      To get in a script the name of the active file use the document property path, for example:

      var sNameOfActiveFile = UltraEdit.activeDocument.path;

      See also General file name evaluating functions.
      Best regards from an UC/UE/UES for Windows user from Austria

      3
      NewbieNewbie
      3

        Aug 20, 2009#3

        Thanks for the quick answer
        Which directory is the current working directory is specified by the options you select at Advanced - Configuration - File Handling - Load
        This is fine, but is there any way to change from a script? If I start ultraedit by command line I wish to change the default directory to the Prompt directory. One of the feature I miss most of MultiEdit is the session management. If I start ME from c:\pippo it automatically loads the session (File open, search history ecc...) I had last time I started ME from c:\pippo. This is very powerfull as you don't have to look for project files on the disk.

        I have done a script which is called automatically by a batch which can load a project file automatically, but I can't change the UE default directory from my script. My idea is to generate in the local (DOS) directory automatically an empty project file (if not already present) called ue.prj for example, and load it automatically each time I call my batch from a prompt box.

        But this can't work unless I am able to know the Prompt local directory from the script.

        By now, I have a workaround: I use an external small application which creates the project file if does not exist and I start UE making it open that project file. But this looks very ugly.

        Giorgio

        6,683583
        Grand MasterGrand Master
        6,683583

          Aug 21, 2009#4

          Setting Use default directory from shortcut on initial file open means current working directory for those users familiar with command prompt.

          I prefer the setting Use active file directory for file open dialog default.

          Help of UE describes the differences and also what is the default for first file open after starting UltraEdit when no files are opend. I have tried to explain how current working directory is handled here. Maybe opening the project file is responsible for setting the current working directory to a directory you don't want. I have not analyzed that.

          I would wish there is a "Default save directory" and a "Default open directory" in the project settings or just a simple "Always use project directory for file open/save as" in the project settings overriding the customized behavior of File - Open / Save As of UltraEdit when no project is open. But unfortunately no such setting (= feature) exists.
          Best regards from an UC/UE/UES for Windows user from Austria

          3
          NewbieNewbie
          3

            Aug 21, 2009#5

            Thank you very much for your help,
            very detailed.

            Giorgio