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

Re: Convert strong with first and last name into two strings

Expand Messages
  • Stephen
    Never mind, I figured it out
    Message 1 of 5 , Jun 3, 2013
      Never mind, I figured it out

      --- In ntb-clips@yahoogroups.com, "Stephen" <freetochoose@...> wrote:
      >
      > Thanks for the help on my question about variables. I've improved my clip, and am now inspire to make it even better.
      >
      > I now want to do something I suspect is common.
      >
      > I want to accept input of a name, e.g. John Altavilla and convert it into two variable Last and first.
      >
      > I think I want to use
      >
      > ^$StrPos("SubStr";"Str";CaseSensitive)$
      >
      > to search for the space, set the position equal to some variable, then use
      >
      > ^$StrCopy("Str";Index;Amount)$
      >
      > to pull out the first name, and again to pull the last name.
      >
      > However, I don't see exactly how to do it, and as it is such a common situation, I'm wondering if there is a simpler way to do it, or if someone already has standard code to do it.
      >
      > Phil
      >
    • Eb
      Phil, I know you figured it out, but... There are better ways to separate multi-word wizard entries. 1. Possibly the best way, a two wizard assignment: ^!Set
      Message 2 of 5 , Jun 10, 2013
        Phil,

        I know you figured it out, but...

        There are better ways to separate multi-word wizard entries.

        1. Possibly the best way, a two wizard assignment:
        ^!Set %first%=^?{Enter first name}; %last%=^?{enter last name}

        2. If you don't like multi-part wizards, an easy way to separate space-delimited strings is to use a space-delimited array:

        ^!SetListDelimiter ^%space%
        ^!SetArray %nameparts%=^?{Enter name}
        ^!Set %first%=^%nameparts1%
        ^!Set %last%=^%nameparts^%nameparts0%%
        ^!If ^%nameparts0%<>3 SKIP
        ^!Set %mi%=^%nameparts2%
        ^!SetListDelimiter ;

        Note: the last line is needed only if you make other array assingments following the above code. Match the delimiter to your needs.



        Cheers,

        Eb


        --- In ntb-clips@yahoogroups.com, "Stephen" <freetochoose@...> wrote:
        > ...
        > accept input of a name, e.g. John Altavilla and convert it into two variable Last and first.
        > ...
        > ^$StrPos("SubStr";"Str";CaseSensitive)$
        > ...
        > ^$StrCopy("Str";Index;Amount)$
        >
        > to pull out the first name, and again to pull the last name.
        >
      • Phil
        Eb, thanks for the suggestions. The first suggestion doesn t work, or, I should say, doesn t accomplish what I want to accomplish. I had a wizard with separate
        Message 3 of 5 , Jun 10, 2013
          Eb, thanks for the suggestions.

          The first suggestion doesn't work, or, I should say, doesn't accomplish what I want to accomplish. I had a wizard with separate fields for first and last names. I was getting tired of copying the first name, then pasting and copying the last name, then pasting.

          I wanted to copy and paste the full name, then parse it out.

          Your second suggestion looks like it fits the bill, and is less awkward than my approach. I will try it. I also see you set it to handle a middle initial if present, ignore otherwise. I need to concatenate the middle initial to the first name, but bet I can figure that out.



          ________________________________
          From: Eb <ebbtidalflats@...>
          To: ntb-clips@yahoogroups.com
          Sent: Monday, June 10, 2013 9:58 AM
          Subject: [Clip] Re: Convert strong with first and last name into two strings



           
          Phil,

          I know you figured it out, but...

          There are better ways to separate multi-word wizard entries.

          1. Possibly the best way, a two wizard assignment:
          ^!Set %first%=^?{Enter first name}; %last%=^?{enter last name}

          2. If you don't like multi-part wizards, an easy way to separate space-delimited strings is to use a space-delimited array:

          ^!SetListDelimiter ^%space%
          ^!SetArray %nameparts%=^?{Enter name}
          ^!Set %first%=^%nameparts1%
          ^!Set %last%=^%nameparts^%nameparts0%%
          ^!If ^%nameparts0%<>3 SKIP
          ^!Set %mi%=^%nameparts2%
          ^!SetListDelimiter ;

          Note: the last line is needed only if you make other array assingments following the above code. Match the delimiter to your needs.

          Cheers,

          Eb

          --- In ntb-clips@yahoogroups.com, "Stephen" <freetochoose@...> wrote:
          > ...
          > accept input of a name, e.g. John Altavilla and convert it into two variable Last and first.
          > ...
          > ^$StrPos("SubStr";"Str";CaseSensitive)$
          > ...
          > ^$StrCopy("Str";Index;Amount)$
          >
          > to pull out the first name, and again to pull the last name.
          >




          [Non-text portions of this message have been removed]
        • Eb
          Hmm, Did you mean, that you are copying and pasting text manually? Anyway, variables concatenate easily in noteTab: ^!Set %x%=^%y% ^%z% ^!Set %x%=^%y%^%z% By
          Message 4 of 5 , Jun 10, 2013
            Hmm,

            Did you mean, that you are copying and pasting text manually?

            Anyway, variables concatenate easily in noteTab:

            ^!Set %x%=^%y% ^%z%
            ^!Set %x%=^%y%^%z%

            By the way, not pertaining to your problem, but generally very useful - the way NT parses lines makes it easy to swap array elements:

            ^!SetArray %x%=One;Two;Three
            ;SWAP elements:
            ^!SetArray %x%=^%x2%;^%x1%
            ^!Info ^%x%


            Revisiting suggestion 1:

            ^!Set %first%=^?{Enter first name}; %last%=^?{enter last name}
            ^!Set %fullname%=^%first% ^%last%

            Revisit 2nd sugg:

            ^!SetListDelimiter ^%space%
            ^!SetArray %nameparts%=^?{Enter name}
            ^!Set %first%=^%nameparts1%
            ^!Set %last%=^%nameparts^%nameparts0%%
            ;------------------------_VV
            ^!If ^%nameparts0%<>3 SKIP_2
            ^!Set %mi%=^%nameparts2%
            ;added line, concat first and mi:
            ^!Set %first%=^%first% ^%mi%
            ;a side effect (benefit) of space-delimited arrays:
            ^!Info [L]Full name:^%tab%^%nameparts%
            ^!SetListDelimiter ;

            Cheers,


            Eb

            --- In ntb-clips@yahoogroups.com, Phil <freetochoose@...> wrote:
            > ... I was getting tired of copying the first name,
            > then pasting and copying the last name, then pasting.
          Your message has been successfully submitted and would be delivered to recipients shortly.