vl-string-left-trim triming

Discussion in 'AutoCAD' started by diemaker, Oct 28, 2004.

  1. diemaker

    diemaker Guest

    Need a sanity check… when stripping off the prefix <$slot_> from a list of strings. vl-string-left-trim removes any “o†from the beginning of the remainder.
    All other letters trim properly, just oh’s, and all oh’s. One string in the list has 8 consecutive oh’s and they all strip off. A hyphen does the same thing. Anyone else get the same?
    Thanks

    (foreach Z (list "$slot_width" "$slot_overall" "$slot_centers"
    "$slot_angle" "$slot_off" "$slot_open"
    "$slot_ooen" "$slot_goon" "$slot_oooooooo8"
    )
    (princ (strcat " " (vl-string-left-trim "$slot_" Z)))
    )
     
    diemaker, Oct 28, 2004
    #1
  2. I get the same thing, except it only strips the 'o's if they are immediately
    after the "$slot_"
    so your list item "$slot_goon" returns "goon" as it should. The rest, it
    strips the 'o's


    strings. vl-string-left-trim removes any "o" from the beginning of the
    remainder.
    the list has 8 consecutive oh's and they all strip off. A hyphen does the
    same thing. Anyone else get the same?
     
    Casey Roberts, Oct 28, 2004
    #2
  3. diemaker

    MP Guest

    that's a weird one alright
    2005 here
    results in vlide console
    _$
    width verall centers angle ff pen en goon 8
    yet another lisp function to stay away from!
    :)


    strings. vl-string-left-trim removes any "o" from the beginning of the
    remainder.
    the list has 8 consecutive oh's and they all strip off. A hyphen does the
    same thing. Anyone else get the same?
     
    MP, Oct 28, 2004
    #3
  4. diemaker

    Jim Claypool Guest

    Use vl-string-subst instead.

    (foreach Z
    (list
    "$slot_width" "$slot_overall" "$slot_centers"
    "$slot_angle" "$slot_off" "$slot_open"
    "$slot_ooen" "$slot_goon" "$slot_oooooooo8"
    )
    (princ (strcat " " (vl-string-subst "" "$slot_" Z)))
    )
     
    Jim Claypool, Oct 28, 2004
    #4
  5. diemaker

    mark Guest

    because the "o" is one of the characters u want to be trimmed,
    the doc is very clear... u can use substr istead

    strings. vl-string-left-trim removes any "o" from the beginning of the
    remainder.
    the list has 8 consecutive oh's and they all strip off. A hyphen does the
    same thing. Anyone else get the same?
     
    mark, Oct 28, 2004
    #5
  6. diemaker

    James Allen Guest

    Ditto. And just to illustrate, try:

    (setq tmp '("$slot_width" "$slot_overall" "$slot_centers"
    "$slot_angle" "$slot_off" "$slot_open"
    "$slot_ooen" "$slot_goon" "$slot_oooooooo8"
    )
    t1 (mapcar '(lambda (a) (vl-string-left-trim "$slot_" a)) tmp)
    t2 (mapcar '(lambda (a) (vl-string-left-trim "_tols$" a)) tmp)
    )

    See the difference between t1 & t2?
     
    James Allen, Oct 29, 2004
    #6
  7. diemaker

    diemaker Guest

    Ok, I see now. You’re right Mark, as always the lisp doc is efficient and precise. James, no I didn’t see a difference between T1 & T2… but that was the point.
    vl-string-subst works great:
    (mapcar '(lambda (A) (vl-string-subst "" "$slot_" A)) TMP)
    Thanks loads.
     
    diemaker, Oct 29, 2004
    #7
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.