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

Re: [Clip] Re: sorting an array

Expand Messages
  • Don - HtmlFixIt.com
    Hi Jeff, I certainly could, but then I have to keep track of what document I am coming from and then get it back. What we have concluded is that I don t need
    Message 1 of 25 , Jul 1, 2009
      Hi Jeff,

      I certainly could, but then I have to keep track of what document I am
      coming from and then get it back. What we have concluded is that I
      don't need to do that. I can work directly on a variable (with ^P as
      separators) or on the clipboard also and that way I need not leave my
      document at all.

      I was doing exactly what you are suggesting which is to sort them and
      then put them back into the array variable.

      I understand it much better (I think anyway) than I did yesterday. We
      can probably try to help you with your clip if you post up the relevant
      parts (or all) and we can probably help you along.

      Don

      Jeff wrote:
      >
      > Don - HtmlFixIt.com wrote:
      > What I didn't want to do
      > was to sort my entire document because that isn't the object I am
      > working on.
      >
      > can you cut the piece to a new document, process it there then cut the
      > finished work back to Doc Prev? That approach worked for my site
      > indexing clip.
      >
    • Jeff
      OK here it is again. The original concept is to highlight a name ( Jeffery G. Scism ) in a document, have the Clip change it to scism-jeffery-g.htm on the
      Message 2 of 25 , Jul 1, 2009
        OK here it is again.

        The original concept is to highlight a name ("Jeffery G. Scism") in a
        document, have the Clip change it to "scism-jeffery-g.htm" on the
        clipboard, so I can autosave the document using that as the file name. I
        don't want to change the name ON te source document, but only the name
        it is saved as. I want it to error out if the Doc already exists. I
        don't want to overwrite existing files. If a file already exists I need
        to merge the new entry, probably manually.

        I had clips that did the name swap in my old computer, but they ere
        lost in a HD Crash.

        I searched the Clips list archive and found some of the previous
        discussion but with what I am starting with I am getting "syntax
        errors" probably due to the improved Reg-ex now in use. It was
        originally written for NoteTab Std 4.95.

        Here is the broken clip I have been working on- it goes NOWHERE. (I
        just can't grasp the concepts apparently).


        __CLIP__

        :PARSE_NAME

        ^!Set %Folder%=^%Drop%
        ^!Toolbar Copy
        ^!SetListDelimiter " "
        ^!SetArray %full_name%=^$GetSelection$
        ^!Set %indexed_name%="^%full_name^%full_name0%%"
        ^!Set %name_counter%=1

        :CreateName
        ^!If ^%name_counter% = ^%full_name0% NameDone
        ^!Set %indexed_name%="^%indexed_name%-^%full_name^%name_counter%%"
        ^!Inc %name_counter%
        ^!Goto CreateName

        :NameDone
        ;strip periods
        ^!Set %indexed_name%=^$StrReplace(".";"";"^%indexed_name%";0;0)

        ^!Set %indexed_name%=^$StrLower("^%indexed_name%")$
        ;(Syntax error this line)
        ^!Set %indexed_name%=^$FileName$.htm

        __/CLIP__/
        /

        Don - HtmlFixIt.com wrote:
        >
        >
        > Hi Jeff,
        >
        > I certainly could, but then I have to keep track of what document I am
        > coming from and then get it back. What we have concluded is that I
        > don't need to do that. I can work directly on a variable (with ^P as
        > separators) or on the clipboard also and that way I need not leave my
        > document at all.
        >
        > I was doing exactly what you are suggesting which is to sort them and
        > then put them back into the array variable.
        >
        > I understand it much better (I think anyway) than I did yesterday. We
        > can probably try to help you with your clip if you post up the relevant
        > parts (or all) and we can probably help you along.
        >
        > Don
        >
        > Jeff wrote:
        > >
        > > Don - HtmlFixIt.com wrote:
        > > What I didn't want to do
        > > was to sort my entire document because that isn't the object I am
        > > working on.
        > >
        > > can you cut the piece to a new document, process it there then cut the
        > > finished work back to Doc Prev? That approach worked for my site
        > > indexing clip.
        > >
        >
        >
        > ------------------------------------------------------------------------
        >
        >
        > No virus found in this incoming message.
        > Checked by AVG - www.avg.com
        > Version: 8.5.375 / Virus Database: 270.13.1/2211 - Release Date: 06/30/09 11:37:00
        >
        >

        --


        Jeffery G. Scism, IBSSG
        Flockmaster,
        International Blacksheep Society of Genealogists

        http://ibssg.org/blacksheep/

        http://bsmeadow.blogspot.com/ Blacksheep's Meadow

        http://www.flickr.com/photos/7764576@N05/ Photostream
      • Don - HtmlFixIt.com
        Okay, first let s start a different thread if you don t mind. Let s start by simpling this down and then building it back up, is that reasonable? How about
        Message 3 of 25 , Jul 1, 2009
          Okay, first let's start a different thread if you don't mind.

          Let's start by simpling this down and then building it back up, is that
          reasonable?

          How about this:
          1. start with the file already open that we want to work on
          2. highlight the name
          3. save the file if doesn't exist already (are we renaming a file?)
          4. give an alert if file already exists

          Is that a good starting point?

          Also what possible parameters are there for the name?
          First I. Last
          First Last
          First Last-LastMore
          First I. Last, Suffix(Jr/Sr/II/III/etc.)

          For now I'll work on the first of those, but thought should be given to
          other variations.

          Don

          Jeff wrote:
          > OK here it is again.
          >
          > The original concept is to highlight a name ("Jeffery G. Scism") in a
          > document, have the Clip change it to "scism-jeffery-g.htm" on the
          > clipboard, so I can autosave the document using that as the file name. I
          > don't want to change the name ON te source document, but only the name
          > it is saved as. I want it to error out if the Doc already exists. I
          > don't want to overwrite existing files. If a file already exists I need
          > to merge the new entry, probably manually.
          >
          > I had clips that did the name swap in my old computer, but they ere
          > lost in a HD Crash.
          >
          > I searched the Clips list archive and found some of the previous
          > discussion but with what I am starting with I am getting "syntax
          > errors" probably due to the improved Reg-ex now in use. It was
          > originally written for NoteTab Std 4.95.
          >
          > Here is the broken clip I have been working on- it goes NOWHERE. (I
          > just can't grasp the concepts apparently).
          >
          >
          > __CLIP__
          >
          > :PARSE_NAME
          >
          > ^!Set %Folder%=^%Drop%
          > ^!Toolbar Copy
          > ^!SetListDelimiter " "
          > ^!SetArray %full_name%=^$GetSelection$
          > ^!Set %indexed_name%="^%full_name^%full_name0%%"
          > ^!Set %name_counter%=1
          >
          > :CreateName
          > ^!If ^%name_counter% = ^%full_name0% NameDone
          > ^!Set %indexed_name%="^%indexed_name%-^%full_name^%name_counter%%"
          > ^!Inc %name_counter%
          > ^!Goto CreateName
          >
          > :NameDone
          > ;strip periods
          > ^!Set %indexed_name%=^$StrReplace(".";"";"^%indexed_name%";0;0)
          >
          > ^!Set %indexed_name%=^$StrLower("^%indexed_name%")$
          > ;(Syntax error this line)
          > ^!Set %indexed_name%=^$FileName$.htm
          >
          > __/CLIP__/
          > /
        • Jeff
          Generally the files are new files not previously saved. Yes, at some cases there is a suffix to the name, like Sr., Jr. I, II, III, etc. Your starting point
          Message 4 of 25 , Jul 1, 2009
            Generally the files are new files not previously saved.

            Yes, at some cases there is a suffix to the name, like Sr., Jr. I, II,
            III, etc.

            Your starting point is exactly right.

            (my transcribers are much faster than I am in coding the pages, this
            would save me enormous amounts of time. I really appreciate it.)

            Jeff

            Don - HtmlFixIt.com wrote:
            >
            >
            > Okay, first let's start a different thread if you don't mind.
            >
            > Let's start by simpling this down and then building it back up, is that
            > reasonable?
            >
            > How about this:
            > 1. start with the file already open that we want to work on
            > 2. highlight the name
            > 3. save the file if doesn't exist already (are we renaming a file?)
            > 4. give an alert if file already exists
            >
            > Is that a good starting point?
            >


            >
            > Also what possible parameters are there for the name?
            > First I. Last
            > First Last
            > First Last-LastMore
            > First I. Last, Suffix(Jr/Sr/II/III/etc.)
            >
            > For now I'll work on the first of those, but thought should be given to
            > other variations.
            >
            > Don
            >
            > Jeff wrote:
            > > OK here it is again.
            > >
            > > The original concept is to highlight a name ("Jeffery G. Scism") in a
            > > document, have the Clip change it to "scism-jeffery-g.htm" on the
            > > clipboard, so I can autosave the document using that as the file
            > name. I
            > > don't want to change the name ON te source document, but only the name
            > > it is saved as. I want it to error out if the Doc already exists. I
            > > don't want to overwrite existing files. If a file already exists I need
            > > to merge the new entry, probably manually.
            > >
            > > I had clips that did the name swap in my old computer, but they ere
            > > lost in a HD Crash.
            > >
            > > I searched the Clips list archive and found some of the previous
            > > discussion but with what I am starting with I am getting "syntax
            > > errors" probably due to the improved Reg-ex now in use. It was
            > > originally written for NoteTab Std 4.95.
            > >
            > > Here is the broken clip I have been working on- it goes NOWHERE. (I
            > > just can't grasp the concepts apparently).
            > >
            > >
            > > __CLIP__
            > >
            > > :PARSE_NAME
            > >
            > > ^!Set %Folder%=^%Drop%
            > > ^!Toolbar Copy
            > > ^!SetListDelimiter " "
            > > ^!SetArray %full_name%=^$GetSelection$
            > > ^!Set %indexed_name%="^%full_name^%full_name0%%"
            > > ^!Set %name_counter%=1
            > >
            > > :CreateName
            > > ^!If ^%name_counter% = ^%full_name0% NameDone
            > > ^!Set %indexed_name%="^%indexed_name%-^%full_name^%name_counter%%"
            > > ^!Inc %name_counter%
            > > ^!Goto CreateName
            > >
            > > :NameDone
            > > ;strip periods
            > > ^!Set %indexed_name%=^$StrReplace(".";"";"^%indexed_name%";0;0)
            > >
            > > ^!Set %indexed_name%=^$StrLower("^%indexed_name%")$
            > > ;(Syntax error this line)
            > > ^!Set %indexed_name%=^$FileName$.htm
            > >
            > > __/CLIP__/
            > > /
            >
            >
            > ------------------------------------------------------------------------
            >
            >
            > No virus found in this incoming message.
            > Checked by AVG - www.avg.com
            > Version: 8.5.375 / Virus Database: 270.13.1/2211 - Release Date: 06/30/09 11:37:00
            >
            >

            --


            Jeffery G. Scism, IBSSG
            Flockmaster,
            International Blacksheep Society of Genealogists

            http://ibssg.org/blacksheep/

            http://bsmeadow.blogspot.com/ Blacksheep's Meadow

            http://www.flickr.com/photos/7764576@N05/ Photostream
          • Jeff Scism
            ... By the way save directory will be the one set by NoteTab in the Options box. Thanks.
            Message 5 of 25 , Jul 1, 2009
              --- In ntb-clips@yahoogroups.com, "Don - HtmlFixIt.com" <don@...> wrote:
              >
              > Okay, first let's start a different thread if you don't mind.
              >
              > Let's start by simpling this down and then building it back up, is that
              > reasonable?
              >
              > How about this:
              > 1. start with the file already open that we want to work on
              > 2. highlight the name
              > 3. save the file if doesn't exist already (are we renaming a file?)
              > 4. give an alert if file already exists
              >

              By the way save directory will be the one set by NoteTab in the Options box.

              Thanks.
            • Don - HtmlFixIt.com
              Well my regex needs work ... it botches Jeff Schism, but works correctly on Jeff G. Schism ... I am trying to cover both situations -- and we should add in the
              Message 6 of 25 , Jul 1, 2009
                Well my regex needs work ... it botches Jeff Schism, but works correctly
                on Jeff G. Schism ...
                I am trying to cover both situations -- and we should add in the
                suffixes too I suspect.

                So file names will be:
                Jeff Schism = schism-jeff--.html
                Jeff G. Schism = schism-jeff-g-.html
                Jeff G. Schism Jr. = schism-jeff-g-jr.html

                or not?

                ^!Continue [C]highlight name and hit control + c

                ;set clipboard to empty
                ^!SetClipboard

                :LoopName
                ;sit her and wait for something to be copied to clipboard
                ^!Delay 5
                ;if nothing on clipboard wait 5 more
                ^!If "^$GetClipboardSize$" = "0" LoopName

                :CheckName
                ;make sure name is First I. Last or First Last
                ^!Find "([A-Za-z]+) ([A-Za-z]*)\.{0,1} {0,1}([A-Za-z]+)" TIHRS
                ^!IfError CheckNameError ELSE ProcessNametoFileName

                :CheckNameError
                ^!Info [C]We expect name to be First I. Last -- bad formatting for
                name^PThis name is -^$GetClipboard$-^Pplease fix and retry
                ^!Goto End


                :ProcessNametoFileName
                ^!SetArray %Array%=^$GetReSubStrings$
                ^!Info [C]^%Array%
                ^!Set %Name%="^$StrLower("^%Array3%-^%Array1%-^%Array2%")$"
                ^!Info [C]Proposed file name:^%Name%.html

                Jeff wrote:
                > Generally the files are new files not previously saved.
                >
                > Yes, at some cases there is a suffix to the name, like Sr., Jr. I, II,
                > III, etc.
                >
                > Your starting point is exactly right.
                >
                > (my transcribers are much faster than I am in coding the pages, this
                > would save me enormous amounts of time. I really appreciate it.)
                >
                > Jeff
                >
                > Don - HtmlFixIt.com wrote:
                >>
                >> Okay, first let's start a different thread if you don't mind.
                >>
                >> Let's start by simpling this down and then building it back up, is that
                >> reasonable?
                >>
                >> How about this:
                >> 1. start with the file already open that we want to work on
                >> 2. highlight the name
                >> 3. save the file if doesn't exist already (are we renaming a file?)
                >> 4. give an alert if file already exists
                >>
                >> Is that a good starting point?
                >>
                >
                >
                >> Also what possible parameters are there for the name?
                >> First I. Last
                >> First Last
                >> First Last-LastMore
                >> First I. Last, Suffix(Jr/Sr/II/III/etc.)
                >>
                >> For now I'll work on the first of those, but thought should be given to
                >> other variations.
                >>
                >> Don
                >>
                >> Jeff wrote:
                >>> OK here it is again.
                >>>
                >>> The original concept is to highlight a name ("Jeffery G. Scism") in a
                >>> document, have the Clip change it to "scism-jeffery-g.htm" on the
                >>> clipboard, so I can autosave the document using that as the file
                >> name. I
                >>> don't want to change the name ON te source document, but only the name
                >>> it is saved as. I want it to error out if the Doc already exists. I
                >>> don't want to overwrite existing files. If a file already exists I need
                >>> to merge the new entry, probably manually.
                >>>
                >>> I had clips that did the name swap in my old computer, but they ere
                >>> lost in a HD Crash.
                >>>
                >>> I searched the Clips list archive and found some of the previous
                >>> discussion but with what I am starting with I am getting "syntax
                >>> errors" probably due to the improved Reg-ex now in use. It was
                >>> originally written for NoteTab Std 4.95.
                >>>
                >>> Here is the broken clip I have been working on- it goes NOWHERE. (I
                >>> just can't grasp the concepts apparently).
                >>>
                >>>
                >>> __CLIP__
                >>>
                >>> :PARSE_NAME
                >>>
                >>> ^!Set %Folder%=^%Drop%
                >>> ^!Toolbar Copy
                >>> ^!SetListDelimiter " "
                >>> ^!SetArray %full_name%=^$GetSelection$
                >>> ^!Set %indexed_name%="^%full_name^%full_name0%%"
                >>> ^!Set %name_counter%=1
                >>>
                >>> :CreateName
                >>> ^!If ^%name_counter% = ^%full_name0% NameDone
                >>> ^!Set %indexed_name%="^%indexed_name%-^%full_name^%name_counter%%"
                >>> ^!Inc %name_counter%
                >>> ^!Goto CreateName
                >>>
                >>> :NameDone
                >>> ;strip periods
                >>> ^!Set %indexed_name%=^$StrReplace(".";"";"^%indexed_name%";0;0)
                >>>
                >>> ^!Set %indexed_name%=^$StrLower("^%indexed_name%")$
                >>> ;(Syntax error this line)
                >>> ^!Set %indexed_name%=^$FileName$.htm
                >>>
                >>> __/CLIP__/
                >>> /
                >>
                >> ------------------------------------------------------------------------
                >>
                >>
                >> No virus found in this incoming message.
                >> Checked by AVG - www.avg.com
                >> Version: 8.5.375 / Virus Database: 270.13.1/2211 - Release Date: 06/30/09 11:37:00
                >>
                >>
                >
              • Don - HtmlFixIt.com
                yeah well lets get it doing the right things with the name first ... progress ... ^!Continue [C]highlight name and hit control + c ;set clipboard to empty
                Message 7 of 25 , Jul 1, 2009
                  yeah well lets get it doing the right things with the name first ...
                  progress ...
                  ^!Continue [C]highlight name and hit control + c

                  ;set clipboard to empty
                  ^!SetClipboard

                  :LoopName
                  ;sit her and wait for something to be copied to clipboard
                  ^!Delay 5
                  ;if nothing on clipboard wait 5 more
                  ^!If "^$GetClipboardSize$" = "0" LoopName

                  :CheckName
                  ;make sure name is First I. Last or First Last
                  ^!Find "([A-Za-z]+) ([A-Za-z])\. ([A-Za-z]+)" TIHRS
                  ^!IfError Next ELSE ProcessNametoFileName
                  ^!Find "([A-Za-z]+) ([A-Za-z]+)" TIHRS
                  ^!IfError CheckNameError ELSE ProcessNametoFileName

                  :CheckNameError
                  ^!Info [C]We expect name to be First I. Last or First Last^Pbad
                  formatting for name^PThis name is -^$GetClipboard$-^Pplease fix and retry
                  ^!Goto End


                  :ProcessNametoFileName
                  ^!SetArray %NameArray%=^$GetReSubStrings$
                  ^!Info [C]^%NameArray%
                  ^!If "^%NameArray0%" = "2" NoMiddle ELSE Middle
                  :Middle
                  ^!Set %Name%="^$StrLower("^%NameArray3%-^%NameArray1%-^%NameArray2%")$"
                  ^!Goto NameOutput
                  :NoMiddle
                  ^!Set %Name%="^$StrLower("^%NameArray2%-^%NameArray1%-")$"
                  :NameOutput
                  ^!Info [C]Proposed file name:^%Name%.html



                  Jeff Scism wrote:
                  > --- In ntb-clips@yahoogroups.com, "Don - HtmlFixIt.com" <don@...> wrote:
                  >> Okay, first let's start a different thread if you don't mind.
                  >>
                  >> Let's start by simpling this down and then building it back up, is that
                  >> reasonable?
                  >>
                  >> How about this:
                  >> 1. start with the file already open that we want to work on
                  >> 2. highlight the name
                  >> 3. save the file if doesn't exist already (are we renaming a file?)
                  >> 4. give an alert if file already exists
                  >>
                  >
                  > By the way save directory will be the one set by NoteTab in the Options box.
                  >
                  > Thanks.
                  >
                  >
                  >
                  > ------------------------------------
                  >
                  > Fookes Software: http://www.fookes.com/
                  > NoteTab website: http://www.notetab.com/
                  > NoteTab Discussion Lists: http://www.notetab.com/groups.php
                  >
                  > ***
                  > Yahoo! Groups Links
                  >
                  >
                  >
                  >
                • Don - HtmlFixIt.com
                  Your assistance was of much help Sheri and Alec! and the magic line that in fact sorts from a semi-colon delimited (that is the default) array back into the
                  Message 8 of 25 , Jul 1, 2009
                    Your assistance was of much help Sheri and Alec!

                    and the magic line that in fact sorts from a semi-colon delimited (that
                    is the default) array back into the same semi-colon delimited array ....
                    all one line ...

                    ^!SetArray
                    %fielddynamics%=^$StrReplace("^P";";";"^$StrSort("^$StrReplace(";";"^P";"^%fielddynamics%";0;0)$";No;Yes;No)$";No;No)$

                    so I had this in fielddynamics when I started:
                    0031:2:33:Place;0005:26:31:Name;0034:22:56:School;0001:3:4:Grade;0056:8:64:Time

                    And this when I'm done:
                    0001:3:4:Grade;0005:26:31:Name;0031:2:33:Place;0034:22:56:School;0056:8:64:Time

                    So it is sorted 1, 5, 31, 34, 56 as it should be.

                    Alec Burgess wrote:
                    > Don ... our messages crossed each other. You are saying much the same as
                    > I did below "-)
                    >
                    > Don - HtmlFixIt.com (don@...) wrote (in part) (on 2009-07-01
                    > at 00:30):
                    > ^!SetClipboard=^$StrSort("^$StrReplace(";";"^P";"12;03;15;99;24;05;54;50";0;0)$";No;Yes;No)$
                    >> ^!SetArray
                    > ew%=^$StrReplace("^P";";";"^$GetClipboard$";0;0)$
                    >> ^!Info [C]^
                    > ew%
                    >> 03;05;12;15;24;50;54;99
                    >>
                    >> If I were willing to use ^P as delimiters think I can get it down to
                    >> one
                    >> line.
                    >>
                    >> ^!SetArray
                    >>
                    > ew%=^$StrSort("^$StrReplace(";";"^P";"12;03;15;99;24;05;54;50";0;0)$";No;Yes;No)$
                    >
                  Your message has been successfully submitted and would be delivered to recipients shortly.