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

Index number of array element

Expand Messages
  • David Talbott
    Hello Group, I want to get the index number of an elements position in an array. For example... ^!SetListDelimiter | ^!SetArray %Array%=fileA|fileB|fileC
    Message 1 of 16 , Jan 30, 2009
      Hello Group,

      I want to get the index number of an elements position in an array.

      For example...

      ^!SetListDelimiter |
      ^!SetArray %Array%=fileA|fileB|fileC

      ;^%array1% = fileA

      It's index number is 1.

      How can I get only it's index number?

      If there already existed a function it would be named ^$GetArrayIndex$
      or something similar. I've been looking through the Clip Script Help
      for two days now and cannot find the answer.

      Thanks for the help,

      - David
    • Don - HtmlFixIt.com
      well I m not sure I understand ... get ^%Array01% s index? How do you know which element you are getting the array index for?
      Message 2 of 16 , Jan 30, 2009
        well I'm not sure I understand ... get ^%Array01%'s index? How do you
        know which element you are getting the array index for?

        David Talbott wrote:
        > Hello Group,
        >
        > I want to get the index number of an elements position in an array.
        >
        > For example...
        >
        > ^!SetListDelimiter |
        > ^!SetArray %Array%=fileA|fileB|fileC
        >
        > ;^%array1% = fileA
        >
        > It's index number is 1.
        >
        > How can I get only it's index number?
        >
        > If there already existed a function it would be named ^$GetArrayIndex$
        > or something similar. I've been looking through the Clip Script Help
        > for two days now and cannot find the answer.
        >
        > Thanks for the help,
        >
        > - David
        >
      • loro
        ... ... I don t think there is anything like that. You have to do it yourself. Something like so. ... H= GetArrayIndex ^!SetListDelimiter | ^!SetArray
        Message 3 of 16 , Jan 30, 2009
          David Talbott wrote:
          >I want to get the index number of an elements position in an array.
          <snip>
          >If there already existed a function it would be named ^$GetArrayIndex$
          >or something similar. I've been looking through the Clip Script Help
          >for two days now and cannot find the answer.

          I don't think there is anything like that. You have to do it
          yourself. Something like so.

          ---------------------------
          H="GetArrayIndex"

          ^!SetListDelimiter |
          ^!SetArray %Array%=fileA|fileB|fileC
          ^!Set %file%=^?{(T=L)What file to find in the array?==^%Array%}

          ^!Set %cntr%=0
          :loop
          ^!Inc %cntr%
          ^!If ^%array^%cntr%% = ^%file% next else loop
          ^!Set %index%=^%cntr%

          ^!Info ^%index%
          ---------------------------

          Lotta
        • David Talbott
          Hi Don, I suppose my example was pretty vague. The element is chosen from an array of checkboxes in a wizard that is populated from a variable array whose
          Message 4 of 16 , Jan 31, 2009
            Hi Don,

            I suppose my example was pretty vague. The element is chosen from an
            array of checkboxes in a wizard that is populated from a variable
            array whose elements are related by index number to elements in other
            arrays. (what did he say?)

            This is a clip to help me back up important client files that change
            frequently. Having to drag-n-drop from some deep location on C:\ to a
            deep location on a flash drive is time consuming. Therefore, I don't
            back up often enough.

            Three arrays are used.

            1) file name without path (populates checkboxes)
            2) file name including path on hard-drive
            3) file name including path on flash-drive

            The locations on the the two drives may change and it is simple to
            make one or two changes in the arrays. Actually, the only location
            that would change might be the back-up on the flash-drive.

            I'm sure it's possible to write my clip more succinctly. It always
            is. But, that will be v2 later. Thank goodness for the help from you
            folks here on this list!

            - David

            Don - HtmlFixIt.com wrote:
            >
            > well I'm not sure I understand ... get ^%Array01%'s index? How do you
            > know which element you are getting the array index for?
            >
            > David Talbott wrote:
            > > Hello Group,
            > >
            > > I want to get the index number of an elements position in an array.
            > >
            > > For example...
            > >
            > > ^!SetListDelimiter |
            > > ^!SetArray %Array%=fileA|fileB|fileC
            > >
            > > ;^%array1% = fileA
            > >
            > > It's index number is 1.
            > >
            > > How can I get only it's index number?
            > >
            > > If there already existed a function it would be named ^$GetArrayIndex$
            > > or something similar. I've been looking through the Clip Script Help
            > > for two days now and cannot find the answer.
            > >
            > > Thanks for the help,
            > >
            > > - David
            > >
            >
          • David Talbott
            ... Perfect, Lotta! Thanks for the loop! Your method of filling the listbox wizard is also easier. I appreciate the help. - David
            Message 5 of 16 , Jan 31, 2009
              >
              > David Talbott wrote:
              > >I want to get the index number of an elements position in an array.
              > <snip>
              > >If there already existed a function it would be named ^$GetArrayIndex$
              > >or something similar. I've been looking through the Clip Script Help
              > >for two days now and cannot find the answer.
              >

              Lotta has the answer! She wrote:

              > I don't think there is anything like that. You have to do it
              > yourself. Something like so.
              >
              > ---------------------------
              > H="GetArrayIndex"
              >
              > ^!SetListDelimiter |
              > ^!SetArray %Array%=fileA|fileB|fileC
              > ^!Set %file%=^?{(T=L)What file to find in the array?==^%Array%}
              >
              > ^!Set %cntr%=0
              > :loop
              > ^!Inc %cntr%
              > ^!If ^%array^%cntr%% = ^%file% next else loop
              > ^!Set %index%=^%cntr%
              >
              > ^!Info ^%index%
              > ---------------------------
              >
              > Lotta
              >

              Perfect, Lotta! Thanks for the loop! Your method of filling the
              listbox wizard is also easier.

              I appreciate the help.

              - David
            • Axel Berger
              ... Not quite what you asked, but: Using Totalcommander you highlight some top level directory on one drive in one window and another on another in the other
              Message 6 of 16 , Jan 31, 2009
                David Talbott wrote:
                > Having to drag-n-drop from some deep location on C:\ to a
                > deep location on a flash drive is time consuming.
                > Therefore, I don't back up often enough.

                Not quite what you asked, but: Using Totalcommander you highlight
                some top level directory on one drive in one window and another on
                another in the other and TC compares them for you. You can then copy
                only the newer and changed files however deep they may be hidden.
                That's how I maintain all my websites. I work on my local copy and
                then update on the server as needed. It is also how I keep some
                folder trees identical on the laptop and the desktop. For
                maintaining backups this is ideal, you copy only the necessary files
                and not any more, making it as quick and painless as can be.

                Axel
              • David Talbott
                This is a good program. I ve seen it around. My backup method is fairly archaic. Burn a couple of CD monthly (soon to be one DVD) and save more frequently
                Message 7 of 16 , Jan 31, 2009
                  This is a good program. I've seen it around.
                  My backup method is fairly archaic. Burn a couple of CD monthly (soon
                  to be one DVD) and save more frequently changed "very important" files
                  onto flash.
                  Totalcommander would soon fill my old, dinky flash drive, but it would
                  be nice to have this option.

                  - David

                  Axel wrote:
                  >
                  > David Talbott wrote:
                  > > Having to drag-n-drop from some deep location on C:\ to a
                  > > deep location on a flash drive is time consuming.
                  > > Therefore, I don't back up often enough.
                  >
                  > Not quite what you asked, but: Using Totalcommander you highlight
                  > some top level directory on one drive in one window and another on
                  > another in the other and TC compares them for you. You can then copy
                  > only the newer and changed files however deep they may be hidden.
                  > That's how I maintain all my websites. I work on my local copy and
                  > then update on the server as needed. It is also how I keep some
                  > folder trees identical on the laptop and the desktop. For
                  > maintaining backups this is ideal, you copy only the necessary files
                  > and not any more, making it as quick and painless as can be.
                  >
                  > Axel
                  >
                • ebbtidalflats
                  I m posting the two-line code workaround from memory, so the syntax for the functions may need tweaking (assumes | as array delimiter): Balnk lines to
                  Message 8 of 16 , Feb 2, 2009
                    I'm posting the two-line code workaround from memory, so the syntax
                    for the functions may need tweaking (assumes |" as array delimiter):

                    Balnk lines to separate long lines:

                    ;find the offset to the array element

                    ^!Set %i%=^$StrPos("|";"|^%array%|";0)$

                    ;count the delimiters in that much of the array

                    ^!Set %i%=^$StrCount("|";"^$StrCopyLeft("|^%array%";^%i%)$")$



                    This code returns the index to the first element it finds. If not
                    found it returns 0.

                    Embedded semicolons in the array content MAY break this code.



                    Eb



                    --- In ntb-clips@yahoogroups.com, "David Talbott" <tmp5@...> wrote:
                    >
                    > Hello Group,
                    >
                    > I want to get the index number of an elements position in an array.
                    >
                    > For example...
                    >
                    > ^!SetListDelimiter |
                    > ^!SetArray %Array%=fileA|fileB|fileC
                    >
                    > ;^%array1% = fileA
                    >
                    > It's index number is 1.
                    >
                    > How can I get only it's index number?
                  • Flo
                    ... Eb, That s another good idea (besides Lotta s solution) but, unfortunately, it s producing a syntax error. I tried to make your idea work. It may look
                    Message 9 of 16 , Feb 3, 2009
                      --- In ntb-clips@yahoogroups.com, "ebbtidalflats" <ebbtidalflats@...>
                      wrote:
                      >
                      > Balnk lines to separate long lines:
                      >
                      > ;find the offset to the array element
                      >
                      > ^!Set %i%=^$StrPos("|";"|^%array%|";0)$
                      >
                      > ;count the delimiters in that much of the array
                      >
                      > ^!Set %i%=^$StrCount("|";"^$StrCopyLeft("|^%array%";^%i%)$")$

                      Eb,

                      That's another good idea (besides Lotta's solution) but,
                      unfortunately, it's producing a syntax error. I tried to make your
                      idea work. It may look something like this...


                      ^!SetListDelimiter |
                      ^!SetArray %Array%=Anthony|Bertha|Carla|David|Eb|Flo
                      ^!Set %Name%=^?{(T=L)Select a name ==^%Array%}
                      ; long line start
                      ^!Set %Index%=^$StrCount(|;^$StrCopyLeft(|^%Array%;^$StrPos(|^%
                      Name;|^%Array%;1)$)$;0;1)$
                      ; long line end
                      ^!Info ^%Name% is number ^%Index%

                      Agreed?

                      Flo
                       
                    • ebbtidalflats
                      Flo, I generally try to keep from nesting too many functions. I lose track. In your code: ; long line start ^!Set
                      Message 10 of 16 , Feb 3, 2009
                        Flo,

                        I generally try to keep from nesting too many functions.
                        I lose track. In your code:

                        ; long line start
                        ^!Set %Index%=^$StrCount(|;^$StrCopyLeft(|^%Array%;^$StrPos(|^%
                        Name;|^%Array%;1)$)$;0;1)$
                        ; long line end


                        in your StrPos, you open a variable "^%name" but don't close it.
                        Other than that the one-liner looks ok. But like chess moves, I can
                        only parse two nested notetab functions in my head <g>.




                        --- In ntb-clips@yahoogroups.com, "Flo" <flo.gehrke@...> wrote:
                        >
                        > --- In ntb-clips@yahoogroups.com, "ebbtidalflats" <ebbtidalflats@>
                        > wrote:
                        > >
                        > > Balnk lines to separate long lines:
                        > >
                        > > ;find the offset to the array element
                        > >
                        > > ^!Set %i%=^$StrPos("|";"|^%array%|";0)$
                        > >
                        > > ;count the delimiters in that much of the array
                        > >
                        > > ^!Set %i%=^$StrCount("|";"^$StrCopyLeft("|^%array%";^%i%)$")$
                        >
                        > Eb,
                        >
                        > That's another good idea (besides Lotta's solution) but,
                        > unfortunately, it's producing a syntax error. I tried to make your
                        > idea work. It may look something like this...
                        >
                        >
                        > ^!SetListDelimiter |
                        > ^!SetArray %Array%=Anthony|Bertha|Carla|David|Eb|Flo
                        > ^!Set %Name%=^?{(T=L)Select a name ==^%Array%}
                        > ; long line start
                        > ^!Set %Index%=^$StrCount(|;^$StrCopyLeft(|^%Array%;^$StrPos(|^%
                        > Name;|^%Array%;1)$)$;0;1)$
                        > ; long line end
                        > ^!Info ^%Name% is number ^%Index%
                        >
                        > Agreed?
                        >
                        > Flo
                        >
                        >
                      • Dan Gagne
                        Eb, This is an excellent clip for discovering field count in menus and in delimited rows (tables). I use it or variations of it extensively for both purposes.
                        Message 11 of 16 , Feb 3, 2009
                          Eb,

                          This is an excellent clip for discovering field count in menus and in
                          delimited rows (tables). I use it or variations of it extensively for
                          both purposes.

                          I've cleaned your code; hopefully making it more readable. Try
                          replacing ones and zeros with true and false as logic parameters. They
                          are more meaningful when you're debugging.

                          I also removed the space characters that cohabitated with your
                          one/zero logic parameters. Parameter fields don't tolerate additional
                          characters.

                          Quotes tend to make literal strings more visible in the string
                          handling function fields (personal choice).
                          ____________________________________
                          ^!SetListDelimiter |
                          ^!SetArray %Array%=Anthony|Bertha|Carla|David|Eb|Flo
                          ^!Set %Name%=^?{(T= L)Select a name ==^%Array%}
                          ; long line start
                          ^!Set
                          %Index%=^$StrCount("|";"^$StrCopyLeft(^%Array%;^$StrPos(^%Name%;^%Array%;true)$)$";false;true)$
                          ; long line end
                          ^!Info ^%Name% is number ^%Index%
                          ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
                          This code should work as intended.

                          best regards,
                          Dan Gagne

                          --- In ntb-clips@yahoogroups.com, "Flo" <flo.gehrke@...> wrote:
                          >
                          > --- In ntb-clips@yahoogroups.com, "ebbtidalflats" <ebbtidalflats@>
                          > wrote:
                          > >
                          > > Balnk lines to separate long lines:
                          > >
                          > > ;find the offset to the array element
                          > >
                          > > ^!Set %i%=^$StrPos("|";"|^%array%|";0)$
                          > >
                          > > ;count the delimiters in that much of the array
                          > >
                          > > ^!Set %i%=^$StrCount("|";"^$StrCopyLeft("|^%array%";^%i%)$")$
                          >
                          > Eb,
                          >
                          > That's another good idea (besides Lotta's solution) but,
                          > unfortunately, it's producing a syntax error. I tried to make your
                          > idea work. It may look something like this...
                          >
                          >
                          > ^!SetListDelimiter |
                          > ^!SetArray %Array%=Anthony|Bertha|Carla|David|Eb|Flo
                          > ^!Set %Name%=^?{(T=L)Select a name ==^%Array%}
                          > ; long line start
                          > ^!Set %Index%=^$StrCount(|;^$StrCopyLeft(|^%Array%;^$StrPos(|^%
                          > Name;|^%Array%;1)$)$;0;1)$
                          > ; long line end
                          > ^!Info ^%Name% is number ^%Index%
                          >
                          > Agreed?
                          >
                          > Flo
                          >  
                          >
                        • Dan Gagne
                          Eb, Forgot to mention that you have to bump the index count by one because the table delimiters follow the field they reference. Hence, the delimiter count is
                          Message 12 of 16 , Feb 3, 2009
                            Eb,

                            Forgot to mention that you have to bump the index count by one because
                            the table delimiters follow the field they reference. Hence, the
                            delimiter count is one less than the field you select.

                            ^!SetListDelimiter |
                            ^!SetArray %Array%=Anthony|Bertha|Carla|David|Eb|Flo
                            ^!Set %Name%=^?{(T= L)Select a name ==^%Array%}
                            ; long line start
                            ^!Set
                            %Index%=^$Calc(^$StrCount("|";"^$StrCopyLeft(^%Array%;^$StrPos(^%Name%;^%Array%;true)$)$";false;true)$+1)$
                            ; long line end
                            ^!Info ^%Name% is number ^%Index%

                            sorry for the oversight.
                            Dan Gagne

                            --- In ntb-clips@yahoogroups.com, "Flo" <flo.gehrke@...> wrote:
                            >
                            > --- In ntb-clips@yahoogroups.com, "ebbtidalflats" <ebbtidalflats@>
                            > wrote:
                            > >
                            > > Balnk lines to separate long lines:
                            > >
                            > > ;find the offset to the array element
                            > >
                            > > ^!Set %i%=^$StrPos("|";"|^%array%|";0)$
                            > >
                            > > ;count the delimiters in that much of the array
                            > >
                            > > ^!Set %i%=^$StrCount("|";"^$StrCopyLeft("|^%array%";^%i%)$")$
                            >
                            > Eb,
                            >
                            > That's another good idea (besides Lotta's solution) but,
                            > unfortunately, it's producing a syntax error. I tried to make your
                            > idea work. It may look something like this...
                            >
                            >
                            > ^!SetListDelimiter |
                            > ^!SetArray %Array%=Anthony|Bertha|Carla|David|Eb|Flo
                            > ^!Set %Name%=^?{(T=L)Select a name ==^%Array%}
                            > ; long line start
                            > ^!Set %Index%=^$StrCount(|;^$StrCopyLeft(|^%Array%;^$StrPos(|^%
                            > Name;|^%Array%;1)$)$;0;1)$
                            > ; long line end
                            > ^!Info ^%Name% is number ^%Index%
                            >
                            > Agreed?
                            >
                            > Flo
                            >  
                            >
                          • ebbtidalflats
                            Thanks for your comments, Dan. ... My code is BELOW the code you have edited. It prefixes the array with an extra delimiter to PREVENT the extra code to
                            Message 13 of 16 , Feb 3, 2009
                              Thanks for your comments, Dan.

                              My response is embedded in the quoted posts below:



                              --- In ntb-clips@yahoogroups.com, "Dan Gagne" <dgagne@...> wrote:
                              >
                              > Eb,
                              >
                              > Forgot to mention that you have to bump the index count by one because
                              > the table delimiters follow the field they reference. Hence, the
                              > delimiter count is one less than the field you select.

                              My code is BELOW the code you have edited. It prefixes the array with
                              an extra delimiter to PREVENT the extra code to increment the index.


                              > ^!Set
                              >
                              %Index%=^$Calc(^$StrCount("|";"^$StrCopyLeft(^%Array%;^$StrPos(^%Name%;^%Array%;true)$)$";false;true)$+1)$
                              > ; long line end
                              > ^!Info ^%Name% is number ^%Index%

                              >
                              > --- In ntb-clips@yahoogroups.com, "Flo" <flo.gehrke@> wrote:
                              > >
                              > > --- In ntb-clips@yahoogroups.com, "ebbtidalflats" <ebbtidalflats@>
                              > > wrote:

                              Note the leading delimiter here

                              > > ^!Set %i%=^$StrPos("|";"|^%array%|";0)$

                              and here (Eb's syntax error corrected) :

                              > > ^!Set %i%=^$StrCount("|";"^$StrCopyLeft("|^%array%";^%i%)$";0;0)$


                              This code includes the leading delimiter, and will return the correct
                              index.


                              > >
                              > > Eb,

                              The guts of Flo's array index, missing '%' and quotes added:

                              ; - - - >8 - - -
                              ^!Set
                              %Index%=^$StrCount("|";^$StrCopyLeft("|^%Array%";^$StrPos("|^%target%";"|^%Array%";1)$)$;0;1)$
                              ; - - - >8 - - -

                              Note: the omitted trailing delimiter allows possible matches to larger
                              elements, that begin with the target. This might be the WRONG index.

                              Better would be (2 delimiters added in the StrPos function):

                              ; - - - >8 - - -
                              ^!Set
                              %Index%=^$StrCount("|";^$StrCopyLeft("|^%Array%";^$StrPos("|^%target%|";"|^%Array%|";1)$)$;0;1)$
                              ; - - - >8 - - -


                              This is more difficult to decipher, than the two-line index code, but
                              works equally well. Perhaps even microscopically faster.




                              Regards,


                              Eb
                            • ebbtidalflats
                              Hi Flo, My original array index code was missing two extra arguments to the StrCount function. That would generate a syntax error. Your code had a missing %
                              Message 14 of 16 , Feb 3, 2009
                                Hi Flo,

                                My original array index code was missing two extra arguments to the
                                StrCount function. That would generate a syntax error.

                                Your code had a missing '%' to the name variable, but there was a
                                difference to my original code that might result in the WRONG index
                                being returned.

                                The initial StrPos function had both the target variable AND the array
                                variable strings enclosed in delimiters. This prevents the clip from
                                finding false matches, where the target starts off a longer array
                                element. See 'Bert' below. There might be some applications where this
                                is ok, but for exact matches, the surrounding delimiters are required.

                                ^!SetArray %Array%=Anthony|Bertha|Bert|Carla|David|Eb|Flo
                                ^!Set %Name%=Bert

                                Search for "|Bert" finds "|Bertha"
                                Search for "|Bert|" finds "|Bert|"


                                The COUNT function does not need a trailing delimiter, since the
                                CopyLeft function only copied to the targets leading delimiter.


                                Count "|" in "|Anthony|Bertha|" returns 3



                                Regards,


                                Eb


                                --- In ntb-clips@yahoogroups.com, "Flo" <flo.gehrke@...> wrote:
                                >
                                > --- In ntb-clips@yahoogroups.com, "ebbtidalflats" <ebbtidalflats@>
                                > wrote:
                                > >
                                > > ^!Set %i%=^$StrCount("|";"^$StrCopyLeft("|^%array%";^%i%)$")$

                                Should have been

                                ^!Set %i%=^$StrCount("|";"^$StrCopyLeft("|^%array%";^%i%)$";0;0)$

                                >
                                >
                                > ^!SetListDelimiter |
                                > ^!SetArray %Array%=Anthony|Bertha|Carla|David|Eb|Flo
                                > ^!Set %Name%=^?{(T=L)Select a name ==^%Array%}
                                > ; long line start
                                > ^!Set %Index%=^$StrCount(|;^$StrCopyLeft(|^%Array%;^$StrPos(|^%
                                > Name;|^%Array%;1)$)$;0;1)$
                                > ; long line end
                                > ^!Info ^%Name% is number ^%Index%
                                >
                                > Agreed?
                              • Flo
                                ... Hi Eb, ... Thanks for these corrections, Eb! It s clear to see why the trailing delimiter is needed. Without that delimiter, Bert , in
                                Message 15 of 16 , Feb 3, 2009
                                  --- In ntb-clips@yahoogroups.com, "ebbtidalflats" <ebbtidalflats@...>
                                  wrote:
                                  >
                                  > Hi Flo,
                                  >
                                  > My original array index code was missing two extra arguments to the
                                  > StrCount function. That would generate a syntax error...

                                  Hi Eb,

                                  > Your code had a missing '%' to the name variable,...
                                  > The initial StrPos function had both the target variable AND
                                  > the array variable strings enclosed in delimiters. This
                                  > prevents the clip from finding false matches, where the target
                                  > starts off a longer array element. See 'Bert' below.

                                  Thanks for these corrections, Eb! It's clear to see why the trailing
                                  delimiter is needed. Without that delimiter, "Bert",
                                  in "Anthony|Bertha|Bert|Carla|David|Eb|Flo", is counted as #2. The
                                  solution is just another "|" in line #4 after ^%Name%.

                                  On this condition, however, we need another delimiter at the end of
                                  the array. Without this delimiter, "Flo" would be counted as "0".
                                  (Normally, a delimiter without a following value could cause some
                                  trouble but, in this case, it doesn't matter.)

                                  In my tests, this works fine...

                                  ^!SetListDelimiter |
                                  ^!SetArray %Array%=Anthony|Bertha|Bert|Carla|David|Eb|Flo|
                                  ^!Set %Name%=^?{(T=L)Select a name==^%Array%}
                                  ; long line start
                                  ^!Set %Index%=^$StrCount(|;^$StrCopyLeft(|^%Array%;^$StrPos(|^%Name%
                                  |;|^%Array%;1)$)$;0;1)$
                                  ; long line end
                                  ^!Info ^%Name% is number ^%Index%


                                  Flo
                                   
                                • ebbtidalflats
                                  Hi Flo, Yes, you need an extra delimiter. However, I would NOT place it at the end of the array. That would require you to structure the array with this
                                  Message 16 of 16 , Feb 5, 2009
                                    Hi Flo,

                                    Yes, you need an extra delimiter. However, I would NOT place it at the
                                    end of the array. That would require you to structure the array with
                                    this particular code in mind, rather than make to index code work with
                                    ANY array.

                                    If you place the extra delimiter at the end of the array within the
                                    string position test, it will always be there, whether the array has a
                                    trailing delimiter or not. Extracting the StrPos function from your
                                    codeline (and adding quotes):

                                    ^$StrPos("|^%name%|";"|^%Array%|";1)$

                                    would parse as either (without trailing delimiter in array:

                                    ^$StrPos("|Flo|";"|Anthony|Bertha|Bert|Carla|David|Eb|Flo|";1)$

                                    or WITH trailing delimiter in the array:

                                    ^$StrPos("|Flo|";"|Anthony|Bertha|Bert|Carla|David|Eb|Flo||";1)$

                                    Then, when you count delimiters, you can drop the trailing delimiters:

                                    ; the whole long line start
                                    ^!Set
                                    %Index%=^$StrCount("|";"^$StrCopyLeft("|^%Array%";^$StrPos("|^%Name%|";"|^%Array%|";1)$)$";0;1)$
                                    ; long line end



                                    Cheers,


                                    Eb

                                    --- In ntb-clips@yahoogroups.com, "Flo" <flo.gehrke@...> wrote:
                                    >
                                    > Thanks for these corrections, Eb! It's clear to see why the trailing
                                    > delimiter is needed. Without that delimiter, "Bert",
                                    > in "Anthony|Bertha|Bert|Carla|David|Eb|Flo", is counted as #2. The
                                    > solution is just another "|" in line #4 after ^%Name%.
                                    >
                                    > On this condition, however, we need another delimiter at the end of
                                    > the array. Without this delimiter, "Flo" would be counted as "0".
                                    > (Normally, a delimiter without a following value could cause some
                                    > trouble but, in this case, it doesn't matter.)
                                    >
                                    > In my tests, this works fine...
                                    >
                                    > ^!SetListDelimiter |
                                    > ^!SetArray %Array%=Anthony|Bertha|Bert|Carla|David|Eb|Flo|
                                    > ^!Set %Name%=^?{(T=L)Select a name==^%Array%}
                                    > ; long line start
                                    > ^!Set %Index%=^$StrCount(|;^$StrCopyLeft(|^%Array%;^$StrPos(|^%Name%
                                    > |;|^%Array%;1)$)$;0;1)$
                                    > ; long line end
                                    > ^!Info ^%Name% is number ^%Index%
                                    >
                                  Your message has been successfully submitted and would be delivered to recipients shortly.