Recalling content from a file in a subdirectory

Recalling content from a file in a subdirectory

1
NewbieNewbie
1

    May 30, 2006#1

    As a newbie, I'm hoping someone can suggest the macro code to do the following.

    With an active file is open (so the path is already known) , I would like to run a macro that:
    1) Opens a file in a subdirectory (the subdirectory will always exist).
    2) Prompts the user to type a text variable. (Using Getstring)
    3) Writes that variable into the file.
    4) Saves the file into the subdirectory with a specific name (i.e. uname.ue) .

    I cannot seem to get the file to write to the nominated subdirectory, - it always defaults to the location of my UE macros.

    Now for the second bit I don't understand at all. If the file in the subdirectory already exists, how can I get the variable stored in the file (from step 3) to appear in the Getstring variable as the default the next time? If the variable value needs to be changed, then overtype it - if not, accept the default offered.

    Thanks

    6,675585
    Grand MasterGrand Master
    6,675585

      May 30, 2006#2

      Comments are highlighted green which must be deleted before copying it to the edit macro dialog. The red highlighted text must be modified by you.

      InsertMode
      ColumnModeOff
      HexOff
      // Copy current filename with path to clipboard 9 and paste it into a new file.
      Clipboard 9
      CopyFilePath
      NewFile
      Paste
      // Remove the filename from the string and add the name of the subdirectory.
      StartSelect
      Find Up Select "\"
      Key RIGHT ARROW
      EndSelect
      Delete
      "subdirname\"
      // Copy the path to clipboard 8.
      SelectToTop
      StartSelect
      Clipboard 8
      Copy
      EndSelect
      // Add to the path the target file name and cut the whole file specification to clipboard 9.
      Key END
      "uname.ue"
      SelectToTop
      StartSelect
      Clipboard 9
      Cut
      EndSelect
      // Paste into the now empty new file the path and add the filename which should be opened. Copy this specification to clipboard 8 and close the new file without saving.
      Clipboard 8
      Paste
      "filename.ext"
      SelectToTop
      Copy
      CloseFile NoSave
      // Open the file. Here you should insert a Find command to find the existing variable text and select it. Make sure the cursor is always positioned at the correct location even if the find command does not find anything. Don't forget to enable macro property Continue if a Find with Replace not found. The current selected variable text is copied to clipboard 8.
      Open "^c"
      IfSel
      Copy
      EndIf
      // It's not possible to launch the GetString dialog with a predefined string. The user can only view the highlighted text in the
      background and confirm the existing text with a special character.

      GetString "Enter text or # if highlighted text is correct:"
      Key LEFT ARROW
      IfCharIs "#"
      Key DEL
      Paste
      EndIf
      // Switch to clipboard 9 and save the file with the new name.
      Clipboard 9
      SaveAs "^c"
      ClearClipboard
      Clipboard 8
      ClearClipboard
      Clipboard 0
      Best regards from an UC/UE/UES for Windows user from Austria