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

Re: [Clip] Easier Date Question

Expand Messages
  • Alan C.
    ... [ . . ] ... The enclosed clip: 1. puts 12 months into array (alphalist) 2. replace each space with a / 2b. replace , with nothing 2c. puts the date string
    Message 1 of 9 , Sep 5, 2004
    • 0 Attachment
      On Fri, 03 Sep 2004 15:48:59 -0700, Alan wrote:
      >�Hi,
      [ . . ]
      >>�For instance, in my doc, the date appears in any one of the
      >>�following formats:
      >>�March 01, 2004
      >>�MAR 1 2004
      >>�03/01/2004
      >>�03/01/04
      >>
      >>�I can select the string, set the variable, but then I need to output
      >>�the date in 2 places in 2 different formats:
      >>�YYYY-MM-DD AND MM/DD/YYYY.

      The enclosed clip:
      1. puts 12 months into array (alphalist)
      2. replace each space with a /
      2b. replace , with nothing
      2c. puts the date string into a 3 item array (mdy)
      3. works/processes separately on each ie mdy1, mdy2, mdy3
      4. manipulates any and all digits during very first stage/section of clip
      5. soon then checks for an alpha string, checks for it on mdy1
      6. if not alpha string, then finaloutput real quick like
      7. or, if is yes alpha string then goto proc (process) alphaitem (procalphaitem). this proc re loops, iterates, comparing each month in alphalist to mdy1 (really at that point mdy1 is or has become: mdy1 > alphaitem > MM). if yes, a match, then substitutes the correct digit replaces the alpha. or, if not a match (foreign calendar item, etc.) then emergency exits the loop, goes to error message at bottom of clip.
      --
      March 01, 2004
      MAR 1 2004
      03/01/2004
      03/01/04
      October 03, 2004
      gaf 04, 2004

      from those, select a line, try the clip if you like.
      the next clip also works if select that gaf month line there :-)
      (Well, ya never know - a Martian calendar might have or use something like that) :-)
      longest clip line equals 59 characters. Clip enclosed next.

      H="date-manip"
      ^!clearvariables
      ^!Set %Date%=^$GetSelection$
      ^!Set %Date%=^$StrReplace(" ";"/";"^%Date%";0;0)$
      ^!Set %Date%=^$StrReplace(",";"";"^%Date%";0;0)$

      ^!Append %alphalist%=jan;feb;mar;apr;may;jun;jul;aug
      ^!SetArray %alphalist%=^%alphalist%;sep;oct;nov;dec

      ^!SetListDelimiter /
      ^!SetArray %mdy%=^%Date%
      ; ^!Info ^%mdy1%~^%mdy2%~^%mdy3%

      ^!Set %DD%=^%mdy2%
      ^!Set %length%=^$StrSize("^%DD%")$
      ^!If ^%length% => 2 skip
      ^!Set %DD%=0^%DD%

      ^!Set %YYYY%=^%mdy3%
      ^!Set %length%=^$StrSize("^%YYYY%")$
      ^!If ^%length% => 4 skip
      ^!Set %YYYY%=20^%YYYY%

      ^!IfTrue ^$IsAlpha("^%mdy1%")$ procalphaitem
      ^!Set %MM%=^%mdy1%

      :finaloutput
      ^!Info ^%YYYY%-^%MM%-^%DD%^p^%MM%/^%DD%/^%YYYY%
      ^!clearvariables
      ^!Goto end

      :procalphaitem
      ^!Set %alphaitem%=^$StrCopyLeft("^%mdy1%";3)$
      ^!Set %alphaitem%=^$StrLower("^%alphaitem%")$

      ^!Set %Count%=^%alphalist0%
      ^!Set %emer_exit%=^%Count%
      ^!Inc %emer_exit% 4
      ^!Set %Index%=0
      :alpha2num
      ^!Inc %Index%
      ^!If ^%Index% > ^%emer_exit% message
      ^!IfSame "^%alphaitem%" "^%alphalist^%Index%%" alpha2digit
      ^!Goto alpha2num

      :alpha2digit
      ^!Set %MM%=^%Index%
      ^!Set %length%=^$StrSize("^%MM%")$
      ^!If ^%length% => 2 skip
      ^!Set %MM%=0^%MM%
      ^!Goto finaloutput
      :message
      ^!Info emergency exited due to no alpha match^pwrong input
      ;---<end_of_clip---

      --
      Alan.
    • Alan
      ... In the effort to create/build, I d copied parts from others of my clips, pasted in, then modified to suite the current clip writing in progress. Due to
      Message 2 of 9 , Sep 5, 2004
      • 0 Attachment
        Alan C. wrote:
        > On Fri, 03 Sep 2004 15:48:59 -0700, Alan wrote:
        >> Hi,
        > [ snip ie see my former post for it has the date-manip clip that's talked about next ]

        In the effort to create/build, I'd copied parts from others of my clips,
        pasted in, then modified to suite the current clip writing in progress.

        Due to that as well as it's not good practice to have a variable that
        never gets used . . .. Of course, it does works fine as it was/is. But
        for those who would opt to change it, then:

        ^!Set %Count%=^%alphalist0%
        ^!Set %emer_exit%=^%Count%
        ^!Inc %emer_exit% 4

        Those above three code lines could be removed and then the next two code
        lines inserted as a replacement (%Count% never gets used except to dump
        off into %emer_exit%).

        ^!Set %emer_exit%=^%alphalist0%
        ^!Inc %emer_exit% 4

        ; ---end--

        BTW: Sometimes during creating a clip I don't get my thinking modified
        fast enough (so as to keep up with what it is that I'm doing). IOW, I
        need visual aid.

        So, the scramble to quickly get from clip idea, get the idea down and
        out in front of me in the editor so that I can see it. (idea retention
        can come and go, sometimes rather quickly, like birds in flight coming
        and going). Though I haven't yet, I guess I could speak it (the idea)
        into a cassette tape for subsequent perusal if needed.

        Yes, psuedo code is good. So is "chunking it down" (dividing the big up
        into smaller pieces) then do a piece at a time.

        --
        Alan.
      • prlproductmanager
        This works great. Thank you so much!!! Rayellen ... output ... of clip ... (procalphaitem). this proc re loops, iterates, comparing each month in alphalist to
        Message 3 of 9 , Sep 7, 2004
        • 0 Attachment
          This works great.
          Thank you so much!!!

          Rayellen

          --- In ntb-clips@yahoogroups.com, "Alan C." <acumming@c...> wrote:
          > On Fri, 03 Sep 2004 15:48:59 -0700, Alan wrote:
          > > Hi,
          > [ . . ]
          > >> For instance, in my doc, the date appears in any one of the
          > >> following formats:
          > >> March 01, 2004
          > >> MAR 1 2004
          > >> 03/01/2004
          > >> 03/01/04
          > >>
          > >> I can select the string, set the variable, but then I need to
          output
          > >> the date in 2 places in 2 different formats:
          > >> YYYY-MM-DD AND MM/DD/YYYY.
          >
          > The enclosed clip:
          > 1. puts 12 months into array (alphalist)
          > 2. replace each space with a /
          > 2b. replace , with nothing
          > 2c. puts the date string into a 3 item array (mdy)
          > 3. works/processes separately on each ie mdy1, mdy2, mdy3
          > 4. manipulates any and all digits during very first stage/section
          of clip
          > 5. soon then checks for an alpha string, checks for it on mdy1
          > 6. if not alpha string, then finaloutput real quick like
          > 7. or, if is yes alpha string then goto proc (process) alphaitem
          (procalphaitem). this proc re loops, iterates, comparing each month
          in alphalist to mdy1 (really at that point mdy1 is or has become:
          mdy1 > alphaitem > MM). if yes, a match, then substitutes the
          correct digit replaces the alpha. or, if not a match (foreign
          calendar item, etc.) then emergency exits the loop, goes to error
          message at bottom of clip.
          > --
          > March 01, 2004
          > MAR 1 2004
          > 03/01/2004
          > 03/01/04
          > October 03, 2004
          > gaf 04, 2004
          >
          > from those, select a line, try the clip if you like.
          > the next clip also works if select that gaf month line there :-)
          > (Well, ya never know - a Martian calendar might have or use
          something like that) :-)
          > longest clip line equals 59 characters. Clip enclosed next.
          >
          > H="date-manip"
          > ^!clearvariables
          > ^!Set %Date%=^$GetSelection$
          > ^!Set %Date%=^$StrReplace(" ";"/";"^%Date%";0;0)$
          > ^!Set %Date%=^$StrReplace(",";"";"^%Date%";0;0)$
          >
          > ^!Append %alphalist%=jan;feb;mar;apr;may;jun;jul;aug
          > ^!SetArray %alphalist%=^%alphalist%;sep;oct;nov;dec
          >
          > ^!SetListDelimiter /
          > ^!SetArray %mdy%=^%Date%
          > ; ^!Info ^%mdy1%~^%mdy2%~^%mdy3%
          >
          > ^!Set %DD%=^%mdy2%
          > ^!Set %length%=^$StrSize("^%DD%")$
          > ^!If ^%length% => 2 skip
          > ^!Set %DD%=0^%DD%
          >
          > ^!Set %YYYY%=^%mdy3%
          > ^!Set %length%=^$StrSize("^%YYYY%")$
          > ^!If ^%length% => 4 skip
          > ^!Set %YYYY%=20^%YYYY%
          >
          > ^!IfTrue ^$IsAlpha("^%mdy1%")$ procalphaitem
          > ^!Set %MM%=^%mdy1%
          >
          > :finaloutput
          > ^!Info ^%YYYY%-^%MM%-^%DD%^p^%MM%/^%DD%/^%YYYY%
          > ^!clearvariables
          > ^!Goto end
          >
          > :procalphaitem
          > ^!Set %alphaitem%=^$StrCopyLeft("^%mdy1%";3)$
          > ^!Set %alphaitem%=^$StrLower("^%alphaitem%")$
          >
          > ^!Set %Count%=^%alphalist0%
          > ^!Set %emer_exit%=^%Count%
          > ^!Inc %emer_exit% 4
          > ^!Set %Index%=0
          > :alpha2num
          > ^!Inc %Index%
          > ^!If ^%Index% > ^%emer_exit% message
          > ^!IfSame "^%alphaitem%" "^%alphalist^%Index%%" alpha2digit
          > ^!Goto alpha2num
          >
          > :alpha2digit
          > ^!Set %MM%=^%Index%
          > ^!Set %length%=^$StrSize("^%MM%")$
          > ^!If ^%length% => 2 skip
          > ^!Set %MM%=0^%MM%
          > ^!Goto finaloutput
          > :message
          > ^!Info emergency exited due to no alpha match^pwrong input
          > ;---<end_of_clip---
          >
          > --
          > Alan.
        Your message has been successfully submitted and would be delivered to recipients shortly.