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

Re: [Clip] Manage Forwarding Lists

Expand Messages
  • Ian NTnerd
    Alex, I think you are selling NoteTab clips short. Clips does not have subroutines as programming languages do you can call other clips or even create simple
    Message 1 of 33 , Jul 5, 2011
    • 0 Attachment
      Alex, I think you are selling NoteTab clips short. "Clips does not have
      subroutines as programming languages
      do" you can call other clips or even create simple functions. I have
      done what you said not to do, though I will admit it can be harder to
      follow.

      Ray, below is a start on automation of the first step. I kept the first
      step and modified the lines. As I don't have the files it is untested.
      You can add more on to your clip or repeat the loop with another sub clip.

      H="Start"
      ; This is main control loop
      ^!clip var
      ^!SetListDelimiter ^p
      ^!setarray %ArrayA%=^$GetClipText("csv")$
      ; the following line calls the LoopA clip with Ray's clip as the clip to
      repeat.
      ^!clip "LoopA" csvgetfiles
      ;The LoopA clip will in turn call csvgetfiles with each file found in
      "_csv" clip below


      H="_var"
      ; I keep variables separate so the main clip is simpler to read.
      ^!set %newpath%=C:\Users\RAS\Documents\
      ^!set %oldpath%=D:\AAI\CompComtee\Forwarding Lists\HC\

      H="_csv"
      ; This is the source for the file names
      HCExecEmails.csv
      HCQOEmails.csv
      HCResearchEmails.csv
      HCSidewalkEmails.csv
      HCTechnicalEmails.csv
      HCActiveEmails.csv

      H="_loopA"
      ; This is my loop that I use all the time. When I am not using regular
      expressions ;-) Have to keep in with the majority RE folk.
      ; It is just a tailored version of the loop found in the "Quick List" F6.
      ^!Set %Indexa%=0
      ^!Set %LoopCounta%=^%arraya0%
      ^!IfCancel End

      :LoopStarta
      ^!Inc %Indexa%
      ^!If ^%Indexa% > ^%LoopCounta% EndLoopa
      ^!If "^%arrayA^%indexA%%"="" LoopStarta
      ^!clip "^&" ^%arraya^%indexa%%

      ^!GoTo LoopStarta
      :EndLoopa


      H="_csvgetfiles"
      ; Ray's clip modified to be a subroutine of the "Start" clip
      ^!SetDebug On
      ; the following line makes a variable of the parameter passed to it. I
      did it for easier readability.
      ^!set %file%=^&

      ;------------>8----------------
      ^!IfFalse ^$IsAltKeyDown$ RUN
      ^!Info [L]description of what this clip does, outputs, inputs, etc.
      ;optional Goto END is advisable with destructive clips
      ^!Goto END
      ;
      :RUN
      ;------------>8----------------

      ^!IfFileExist "^%oldpath%^%file%" DoesNewFileExist NoOldFile

      :DoesNewFileExist
      ^!IfFileExist "^%newpath%^%file%" BothFilesExist NoNewFile

      :BothFilesExist
      ^!Open "^%oldpath%^%file%"
      ^!Save AS "^%oldpath%^%file%OLD.csv"
      ^!Open "^%newpath%^%file%"
      ^!Save AS "^%newpath%^%file%NEW.csv"

      :NormalEnding
      ^!INFO Two files are ready for comparison.
      ^!GoTo exit

      :NoOldFile
      ^!INFO Can't find ^%oldpath%^%file%^pAborting
      ^!GoTo exit

      :NoNewFile
      ^!INFO Can't find ^%newpath%^%file%^pAborting
      ^!GoTo exit

      ----------------------------------------
      Hope it helps.

      Ian

      On 5/07/2011 10:04 AM, Axel Berger wrote:
      >
      > Ray Shapp wrote:
      > > I think it might be best if the six file names were stored
      > > in an array, and an integrated clip were to loop six times.
      >
      > Possibly, but I'd choose a different approach. As you have to write down
      > those six paths anyway, I'd make do without a formal loop and write the
      > main code linearly for all six. Arrays and indices only invite hard to
      > find mistakes. Clips does not have subroutines as programming languages
      > do, it lacks the RETURN command, but unless I'm mistaken you can use
      > what FORTRAN calls "assigned gotos", i.e:
      >
      > ^!Goto ^%return%
      >
      > So your main part would mainly consist of ^!Set directives and after
      > setting the proper return points you call "subroutines" with ^!Goto.
      >
      > > Also, how does one force "save as" if the file name
      > > is already in use?
      >
      > Save or close the offending second document first. You can swap the
      > active focus with ^!Document [FIRST|LAST|NEXT|PREV]
      >
      > Axel
      >
      >



      [Non-text portions of this message have been removed]
    • Eb
      Hi Ray, I took a closer look at your code. There are several syntax problems. 1. You _must_ use the end label in a subroutine clip (cvs) rather than exit ,
      Message 33 of 33 , Jul 20, 2011
      • 0 Attachment
        Hi Ray,

        I took a closer look at your code. There are several syntax problems.

        1. You _must_ use the "end" label in a subroutine clip (cvs)
        rather than "exit", if you want to return to the caller.
        Using the EXIT label ends execution right then
        and does NOT return to the caller.
        In other words:
        ^!Goto END

        2. Syntax error and redundant:
        a) ^!Setfocus ^%WorkingFile%.csv
        does nothing
        b) ^!SetFocus DOCUMENT
        would change focus to the document window,
        if it weren't already there from the ^!Open command
        The command, if correct, would be redundant.

        3. Confusing code in the destroy subroutine
        a. ^!Close "^&"
        closes the document in NoteTab, leaves disk file intact
        if you also want to delete the disk file, you could
        now use
        ^!DeleteFile filename
        or use the next command by itself
        b. ^!DestroyDoc "^&"
        closes open doc and sends the file to the recycle bin

        c. If the file is NOT open in NoteTab, use
        ^!DeleteFile filename


        4. Finally, your main cvs code does not make sense
        a. why bother to do any replacements in the old file,
        when you delete it in the next line?
        b. why save the new file before opening it?

        I suggest you start from scratch, by outlining the steps you would like to take, and then converting the individual steps to code.

        Cheers,

        Eb
      Your message has been successfully submitted and would be delivered to recipients shortly.