Loading ...
Sorry, an error occurred while loading the content.

Re: create a dialog to get a file name

Expand Messages
  • mblattyh
    ... Can ... clip ... It ... I just a few days ago set up a clip to display a group of files and then open a some or all of them in NoteTab. It is a
    Message 1 of 2 , Mar 2, 2006
    • 0 Attachment
      --- In ntb-clips@yahoogroups.com, "dpasseng" <don@...> wrote:
      >
      > I want to run a directory with a clip. Find all files named *.txt,
      > create a dialog box with each name and be able to select one. Once
      > selected I want to populate a variable with that name. Thoughts?
      Can
      > this be done? What I am eventually hoping to do is open that file
      > with another program, and that I do know how to do from a prior
      clip
      > where I had the filename selected ...
      > ^!Set %TempVar%=^$GetSelection$
      > ^!Replace "%20" >> " " ATIHS
      > ^!C:\Program Files\IrfanView\i_view32.exe ^%TempVar%
      >
      > I think the latter might better be Shell actually but no matter.
      It
      > is the first part I need help with.
      >

      I just a few days ago set up a clip to display a group of files and
      then open a some or all of them in NoteTab. It is a modification of
      a discussion in this group from Feb.9th-10th. Here's my clip:

      ; save in a variable the starting folder
      ^!Set %folder%=^?{(T=D)Enter a starting folder or click the button
      to search=D:\Tab\}

      ; run the DOS DIR command on the folder name entered above and stuff
      into a variable -
      ; \*. gets only files with no extension, /a-d shows non-directory
      files only, /b shows barebones info
      ^!Set %list%=^$GetDosOutput("dir ^%folder%\*. /a-d /b")$

      ; Convert ^%list% variable so it fits into an array check box
      NoteTab wizard
      ; 1. Replace all ^p with |
      ; 2. Put _ before each file name to make them all default (so boxes
      are checked as default)
      ; 3. Remove right most 2 characters (NT puts ^p at the end of ^%
      list% variable, and we change that to |_)
      ^!Set %listnames%=_^$StrDeleteRight("^$StrReplace("^p";"|_";"^%
      list%";false;false)$";2)$

      ; Create check-box array with spec file names in it
      ^!SetArray %filen%=^?{(T=A;h=20)Choose filenames=^%listnames%}

      ; Initialize loop counter
      ^!Set %fn%=1

      ; Loop to open files
      :STARTLOOP
      ^!Open ^%folder%\^%filen^%fn%%
      ^!Inc %fn%
      ^!If ^%fn% > ^%filen0% ENDLOOP else STARTLOOP
      :ENDLOOP

      I think the changes you'll need are:
      1. Change the "*." to "*.txt" in the ^!Set %list%... line
      2. Don't use the underline on each file name in the ^!Set %
      listnames% ... line. You probably don't want your checkbox list pre-
      populated with check marks.
      3. Replace my loop to open files with your commands to open your
      application. If you only choose one file to act upon, it's name
      should end up in a variable called %filen1%.

      I hope this helps.
    Your message has been successfully submitted and would be delivered to recipients shortly.