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

variations on a theme...

Expand Messages
  • BHCS
    The clip to parse/select/cut/paste records from a .csv file works very nicely, incl the additions of deleting the selected records from the source doc & making
    Message 1 of 2 , Nov 5, 2003
    • 0 Attachment
      The clip to parse/select/cut/paste records from a .csv file works very
      nicely, incl the additions of deleting the selected records from the
      source doc & making it case insensitive. Now I want more now that I see
      some possibilities that I hadn't thought about before in terms of
      analyzing where/what we spend most of our time on, etc.

      So I used the clip to make a new one to add to my billables library, but
      it doesn't work right. This clip...

      ; selects & cuts all records that match user supplied value for 1st field
      ^!Set %scratchdoc%=temp_tasks.txt
      ^!Set %path%="R:\Clients\BillableHrs\"
      ^!Set %whattask%=^?[What Task?]
      ^!Set %period%=^?[What Billing Period?]
      ^!IfFileExist "^%path%^%scratchdoc%" skip
      ^!GoTo skip
      ^!DeleteFile "^%path%^%scratchdoc%"
      ^!Jump Doc_Start
      :repeat
      ^!Find ""^%whattask%".*",".*",".*",".*",".*",".*",".*",".*"" RSI
      ^!IfError finish
      ^!AppendToFile "^%path%^%scratchdoc%" ^$GetSelection$^%NL%
      ^!Replace "^$GetSelection$" >> "^%EMPTY%" IS
      ^!GoTo repeat
      :finish
      ^!Open "^%path%^%scratchdoc%"
      ^!SetWizardLabel "Save to ^%path%"
      ^!Set %new_name%=^?{As:=^%whattask%-^%period%.txt}
      ^!IfFileExist "^%path%^%new_name%" warn
      ^!RenameDoc ^%new_name%
      ^!GoTo end
      :warn
      ^!Skip A file named ^%path%^%new_name% already exists. Overwrite?
      ^!GoTo end
      ^!DeleteFile "^%path%^%new_name%"
      ^!RenameDoc ^%new_name%
      ; -----<end of clip<-----

      ... produces an Information dialog that says the "File
      R:\Clients\BillableHrs\temp-tasks.txt does not exist." I click Ok & it
      prompts me to save with a name that matches the whattask+period vars but
      I'm still in the source doc with nothing selected & it'll get renamed
      unless I [Cancel] out of the Save dialog.

      Thought I understood the clip but obviously I'm missing something here.
      Where is that 'File ... does not exist" dialog coming from - I don't see
      anything in the clip code that would launch it????

      Also, in this case I want to only write the 1st, 2nd, 3rd, 5th & 8th
      fields to the new doc but I want to delete all of the fields from the
      source record - how is that done?

      As always - thanks for the help.

      Bill
    • Ben B
      On Wednesday, Nov 05, 2003 BHCS wrote regarding variations on a theme... ; ... Hi Bill, The error was being generated at ^!Open ^%path%^%scratchdoc%
      Message 2 of 2 , Nov 6, 2003
      • 0 Attachment
        On Wednesday, Nov 05, 2003
        BHCS wrote regarding "variations on a theme...";

        > .. produces an Information dialog that says the "File
        > R:\Clients\BillableHrs\temp-tasks.txt does not exist." I click Ok & it
        > prompts me to save with a name that matches the whattask+period vars but
        > I'm still in the source doc with nothing selected & it'll get renamed
        > unless I [Cancel] out of the Save dialog.

        Hi Bill,

        The error was being generated at
        ^!Open "^%path%^%scratchdoc%"
        (^!SetDebug is useful for troubleshooting these things)
        because the regexp failed and thus the file was never created.

        > Also, in this case I want to only write the 1st, 2nd, 3rd, 5th & 8th
        > fields to the new doc but I want to delete all of the fields from the
        > source record - how is that done?

        Here's another clip you can try. See if this does what you want.
        Watch out for line wrap, every line begins with either a command (begins
        with ^!) or a label (begins with :) except for a couple of comments (;)
        preceding lines likely to wrap.

        H="variations"
        ^!Set %path%="R:\Clients\BillableHrs\"
        ^!Set %whattask%=^?[What Task?]
        ^!Set %period%=^?[What Billing Period?]
        ^!Set %filename%=^%path%^%whattask%-^%period%.txt
        ^!Set %tempfile%=^$GetTempFile$
        ^!Jump Doc_Start
        :repeat
        ^!Find ""^%whattask%",".*",".*",".*",".*",".*",".*",".*"" RSI
        ^!IfError finish
        ^!AppendToFile "^%tempfile%" ^$GetSelection$^%NL%
        ^!Replace "^$GetSelection$" >> ""
        ^!GoTo repeat
        :finish
        ^!Open "^%tempfile%"
        ;long line follows
        ^!Replace "{".*"},{".*"},{".*"},".*",{".*},".*",".*",{".*"}" >> "\1,\2,\3,\4,\5" RAWS
        ^!IfFileExist "^%filename%" warn Else Skip_3
        :warn
        ^!Skip ^%filename%^%NL%already exists!^%NL%^%NL%Overwrite?
        ^!GoTo choose
        ^!Save AS ^%filename%
        ^!DeleteFile ^%tempfile%
        ^!GoTo Exit
        :choose
        ;long line follows
        ^!Save AS ^?{(T=S)Choose a different folder or change filename=^%filename%}
        ^!DeleteFile ^%tempfile%
        ; -----<end of clip<-----

        HTH
        Ben B
      Your message has been successfully submitted and would be delivered to recipients shortly.