Announcement

Collapse

New Sub-Forum

In an effort to help make sure there are appropriate categories for topics of discussion that are happening, there is now a sub-forum for databases and database programming under Special Interest groups. Please direct questions, etc., about this topic to that sub-forum moving forward. Thank you.
See more
See less

Simple question

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Simple question

    In a list of names such as:
    john L jones
    john jones
    mary ann smith
    sam smith

    How can I strip off and use the last names only?
    I know (dumb question)but the solution just escapes me.
    Any help will be appreciated.

    Regards,
    Lloyd

  • #2
    Locate the last whitespace character in each string and use it's position to extract the last name from the string.

    Code:
    'psuedo code - using indexed pointers with PB3.5 is much faster!
    for x% = len(a$) to 1 step -1
      if mid(a$,x%,1) = chr$(32) then
        b$ = mid$(a$, x% + 1)
        exit for
      end if
    next x%
    ' Now b$ contains the characters after tha last space character.
    If we build another array containing the results obtained in b$ and then sort that array using the original array as a TAGARRAY, the result is a sorted array.


    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>
    Lance
    mailto:[email protected]

    Comment

    Working...
    X