Alpha Video Training
Results 1 to 15 of 15

Thread: Left trim ?

  1. #1
    Member
    Real Name
    John Mucci
    Join Date
    Nov 2010
    Location
    New York
    Posts
    308

    Default Left trim ?

    Question, I know you can use left trim to reduce a field lenght.

    I want to take a "Character" Field which has a name and number. example: tom * 123456

    and trim everything after the * BTW I can not number eliminate the numbers, cause some names contain numbers.

    Does anyone know which function to use?

    Thanks,
    john

  2. #2
    "Certified" Alphaholic DaveM's Avatar
    Real Name
    Dave Mason
    Join Date
    Jul 2000
    Location
    Hudson, FL
    Posts
    5,986

    Default Re: Left trim ?

    dim nme as c = "tom * 1234"
    dim nme2 as c
    nme2 = *word_remove(nme, 2, " ")
    ? alltrim(*word_remove(nme2, 2, " "))
    = "tom"
    Dave Mason
    dave@aldaweb.com

    Skype is dave.mason46

  3. #3
    Member
    Real Name
    John Mucci
    Join Date
    Nov 2010
    Location
    New York
    Posts
    308

    Default Re: Left trim ?

    Thank you dave can you use Dim functions in Qbuilder?
    John

  4. #4
    "Certified" Alphaholic DaveM's Avatar
    Real Name
    Dave Mason
    Join Date
    Jul 2000
    Location
    Hudson, FL
    Posts
    5,986

    Default Re: Left trim ?

    I really do not know anything about qbuilder.

    There are other ways to accomplish the above. Some are simpler? This was quick just using help and not looking a whole lot.
    Dave Mason
    dave@aldaweb.com

    Skype is dave.mason46

  5. #5
    "Certified" Alphaholic
    Real Name
    Mike Christensen
    Join Date
    Nov 2005
    Location
    Michigan U.P.
    Posts
    5,937

    Default Re: Left trim ?

    John,
    QRB is built upon Alpha and has almost every functionality it has.

    take a "Character" Field which has a name and number. example: tom * 123456

    and trim everything after the *
    The following assumes that there will only be one "*" in the string to be parsed....and that every record will have same.
    I take it as you also want the "*" included. So if doing this for all the data in a field:
    Code:
    Maybe word(your_field_name, 1, "*") + " *"
    or just for the example given:
    Code:
    word("tom * 123456", 1, "*") + " *"
    [/CODE]
    Mike
    __________________________________________
    It is only when we forget all our learning that we begin to know.
    It's not what you look at that matters, it's what you see.
    Henry David Thoreau
    __________________________________________




  6. #6
    Member
    Real Name
    John Mucci
    Join Date
    Nov 2010
    Location
    New York
    Posts
    308

    Default Re: Left trim ?

    Mike sorry I would like to delete the * and everything to the right of it ..

    John

  7. #7
    Moderator
    Real Name
    Alan Buchholz
    Join Date
    Oct 2000
    Location
    Delavan, Wisconsin
    Posts
    9,561

    Default Re: Left trim ?

    Code:
    a="tom * 123456"
    ?a
    = "tom * 123456"
    
    ?word(a,1,"*")
    = "tom "
    ?word(a,1," *")
    = "tom"
    Al Buchholz
    Bookwood Systems, LTD
    Weekly QReportBuilder Webinars Thursday 1 pm CST

    Occam's Razor - KISS
    Normalize till it hurts - De-normalize till it works.
    Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
    When we triage a problem it is much easier to read sample systems than to read a mind.

  8. #8
    "Certified" Alphaholic
    Real Name
    Tom Cone Jr
    Join Date
    Apr 2000
    Location
    Florida
    Posts
    23,300

    Default Re: Left trim ?

    Here's yet another approach:

    Code:
    substr(a, 1, at("*", a)-1)
    This extracts a substring from the string in the variable named "a", beginning at position 1 and continuing to one position before the asterisk.

    And more simply:

    Code:
    left(a, at("*",a)-1)

  9. #9
    Member
    Real Name
    John Mucci
    Join Date
    Nov 2010
    Location
    New York
    Posts
    308

    Default Re: Left trim ?

    Thanks that worked.
    left(a, at("*",a)-1)
    John

  10. #10
    "Certified" Alphaholic DaveM's Avatar
    Real Name
    Dave Mason
    Join Date
    Jul 2000
    Location
    Hudson, FL
    Posts
    5,986

    Default Re: Left trim ?

    Wow, Tom,

    I did not remember that one and jyust did not spend the time I should have in the help files.
    Dave Mason
    dave@aldaweb.com

    Skype is dave.mason46

  11. #11
    Member
    Real Name
    John Mucci
    Join Date
    Nov 2010
    Location
    New York
    Posts
    308

    Default Re: Left trim ?

    Now that we know word() works to take out the characters to the right.

    What do you change if you want to take out all characters to the left of a *?

    Thanks
    John

  12. #12
    Moderator
    Real Name
    Alan Buchholz
    Join Date
    Oct 2000
    Location
    Delavan, Wisconsin
    Posts
    9,561

    Default Re: Left trim ?

    Use the appropriate word number (argument 2) or the number of word (argument 4)
    WORD1.PNG

    It may help to think in terms of what do I get rather than what am I eliminating... (it's always good to be positive..)
    Last edited by Al Buchholz; 05-23-2011 at 02:23 PM.
    Al Buchholz
    Bookwood Systems, LTD
    Weekly QReportBuilder Webinars Thursday 1 pm CST

    Occam's Razor - KISS
    Normalize till it hurts - De-normalize till it works.
    Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
    When we triage a problem it is much easier to read sample systems than to read a mind.

  13. #13
    Member
    Real Name
    John Mucci
    Join Date
    Nov 2010
    Location
    New York
    Posts
    308

    Default Re: Left trim ?

    Thanks Al the problem I face is, the total words are not the same for each part number. I have one word which will always stay the same (Lot No.:) so I would like to take out all words leading up to the ":"

    Example: USP 40-80 Mesh Packed in 50 kg. drums Lot No.: 1135
    Result: 1135


    John

  14. #14
    Moderator
    Real Name
    Alan Buchholz
    Join Date
    Oct 2000
    Location
    Delavan, Wisconsin
    Posts
    9,561

    Default Re: Left trim ?

    Code:
    a="USP 40-80 Mesh Packed in 50 kg. drums Lot No.: 1135"
    
    ?a
    
    ?word(a,1,":")
    = "USP 40-80 Mesh Packed in 50 kg. drums Lot No."
    
    ?word(a,2,":")
    = " 1135"
    It took me a while to wrap my head around 'word()'

    In this case the word count is not limited to the 'classic word' - ie there are not 11 words in your string when you delimited by ":" - there are only 2 - since there is only one ":" in the string...
    Al Buchholz
    Bookwood Systems, LTD
    Weekly QReportBuilder Webinars Thursday 1 pm CST

    Occam's Razor - KISS
    Normalize till it hurts - De-normalize till it works.
    Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
    When we triage a problem it is much easier to read sample systems than to read a mind.

  15. #15
    Member
    Real Name
    John Mucci
    Join Date
    Nov 2010
    Location
    New York
    Posts
    308

    Default Re: Left trim ?

    That makes it easy :) Thanks Al

    John
    Last edited by Al Buchholz; 05-23-2011 at 04:40 PM.

Similar Threads

  1. Trim command
    By deputy956 in forum Alpha Five Version 8
    Replies: 2
    Last Post: 12-07-2010, 06:53 AM
  2. Trim last names
    By lkatz1 in forum Alpha Five Version 5
    Replies: 1
    Last Post: 01-11-2009, 01:34 AM
  3. Trim
    By Fletch in forum Alpha Five Version 7
    Replies: 6
    Last Post: 02-20-2006, 03:29 PM
  4. Trim Fields, HELP
    By chadg@epix.net in forum Alpha Five Version 5
    Replies: 4
    Last Post: 12-17-2004, 07:11 AM
  5. Help with Trim Function
    By imwest@cox.net in forum Alpha Five Version 4
    Replies: 4
    Last Post: 07-22-2002, 10:59 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •