Results 1 to 12 of 12

Thread: Ah! the dilemma, and the posibilities...

  1. #1
    Rudy Tovar Guest

    Ah! the dilemma, and the posibilities...

    Before I actually get started, perhaps someone has already done this... it's
    actually a no brainer, but like to see if anyone has come up with a
    condensed version that's a bit more efficient...

    OK...

    First a text a file that contains...

    ****THIS COMMENT OR THAT****

    **122 LINE ONE
    **123 LINE TWO
    **124 LINE THREE

    ********************************

    Considering it may contain spaces and more comments, I'd like to be able to
    use vl-position to located number "122" in a list that I'll be creating of a
    file reference.

    Also, eliminate any spaces, or tabs when returning the reference number
    "LINE ITEM NOTE".

    <list> = ("****THIS COMMENT OR THAT****" "" "**122 LINE ONE"
    .....etc.....)

    In the end I'd like to say (get-note "123" <list>) and all it returns is
    "LINE TWO" without any spaces or tabs in front of the note...

    I'd like to eliminate possibilities that someone may use spaces, tabs or
    both when writing the line item note.

    I know I could come up with a simple solution, but I'd like to see if
    someone may have a more efficient method, instead of having to compare each
    character in the LINE considering that the list could contain hundreds or
    items listed.

    Thank you for your comments

  2. #2
    Michael Puckett Guest
    What about using vl-string-trim, vl-string-search etc. to suit ...

    (vl-string-trim " */t" "***122 LINE ONE")

    => "122 LINE ONE"

    (if
    (setq pos
    (vl-string-search
    " "
    (setq temp
    (vl-string-trim
    " */t"
    "**122 LINE ONE"
    )
    )
    )
    )
    (substr temp 1 pos)
    )

    => "122"

    Etc.

    "Rudy Tovar" <Rudy@CadentityNoSpam.com> wrote in message news:41c861bd$1_3@newsprd01...
    Before I actually get started, perhaps someone has already done this... it's
    actually a no brainer, but like to see if anyone has come up with a
    condensed version that's a bit more efficient...

    OK...

    First a text a file that contains...

    ****THIS COMMENT OR THAT****

    **122 LINE ONE
    **123 LINE TWO
    **124 LINE THREE

    ********************************

    Considering it may contain spaces and more comments, I'd like to be able to
    use vl-position to located number "122" in a list that I'll be creating of a
    file reference.

    Also, eliminate any spaces, or tabs when returning the reference number
    "LINE ITEM NOTE".

    list> = ("****THIS COMMENT OR THAT****" "" "**122 LINE ONE"
    ....etc.....)

    In the end I'd like to say (get-note "123" <list>) and all it returns is
    "LINE TWO" without any spaces or tabs in front of the note...

    I'd like to eliminate possibilities that someone may use spaces, tabs or
    both when writing the line item note.

    I know I could come up with a simple solution, but I'd like to see if
    someone may have a more efficient method, instead of having to compare each
    character in the LINE considering that the list could contain hundreds or
    items listed.

    Thank you for your comments

  3. #3
    Rudy Tovar Guest
    Thanks Michael, but I don't think the number reference would be to
    difficult, rather the contents after the number, which could include tabs or
    spaces, as I illustrated...I just don't want to go through another loop to
    get the note contents...

    Here's what I have...(masi-get-reference) is stored in drawing, but could be
    any file name.

    (defun c:test (/ file ofile oline olist)

    (setq file (masi-get-reference))

    (if (findfile file)
    (progn

    (setq ofile (open file "r"))
    (while (setq oline (read-line ofile))
    (setq olist (cons oline olist)
    nlist (cons (substr oline 1 5) nlist)
    )

    );end of while
    (close ofile)
    )
    )

    (list (reverse nlist)(reverse olist))
    )



    "Michael Puckett" <Sp@mYourself.Sucka> wrote in message
    news:41c867cf$1_1@newsprd01...
    What about using vl-string-trim, vl-string-search etc. to suit ...

    (vl-string-trim " */t" "***122 LINE ONE")

    => "122 LINE ONE"

    (if
    (setq pos
    (vl-string-search
    " "
    (setq temp
    (vl-string-trim
    " */t"
    "**122 LINE ONE"
    )
    )
    )
    )
    (substr temp 1 pos)
    )

    => "122"

    Etc.

    "Rudy Tovar" <Rudy@CadentityNoSpam.com> wrote in message
    news:41c861bd$1_3@newsprd01...
    Before I actually get started, perhaps someone has already done this...
    it's
    actually a no brainer, but like to see if anyone has come up with a
    condensed version that's a bit more efficient...

    OK...

    First a text a file that contains...

    ****THIS COMMENT OR THAT****

    **122 LINE ONE
    **123 LINE TWO
    **124 LINE THREE

    ********************************

    Considering it may contain spaces and more comments, I'd like to be able
    to
    use vl-position to located number "122" in a list that I'll be creating
    of a
    file reference.

    Also, eliminate any spaces, or tabs when returning the reference number
    "LINE ITEM NOTE".

    list> = ("****THIS COMMENT OR THAT****" "" "**122 LINE ONE"
    ....etc.....)

    In the end I'd like to say (get-note "123" <list>) and all it returns is
    "LINE TWO" without any spaces or tabs in front of the note...

    I'd like to eliminate possibilities that someone may use spaces, tabs or
    both when writing the line item note.

    I know I could come up with a simple solution, but I'd like to see if
    someone may have a more efficient method, instead of having to compare
    each
    character in the LINE considering that the list could contain hundreds or
    items listed.

    Thank you for your comments



  4. #4
    Rudy Tovar Guest
    Just so you know I could now use the vl-position to return the remaining
    values, but would like to see if it could be condensed a bit more to strip
    any spaces and or tabs.

    The illustrated function returns 2 list, one that contains the first 5
    charcters, and the second listing that returns anything remaining on that
    line...



    "Rudy Tovar" <Rudy@CadentityNoSpam.com> wrote in message
    news:41c86a01$1_2@newsprd01...
    Thanks Michael, but I don't think the number reference would be to
    difficult, rather the contents after the number, which could include tabs
    or spaces, as I illustrated...I just don't want to go through another loop
    to get the note contents...

    Here's what I have...(masi-get-reference) is stored in drawing, but could
    be any file name.

    (defun c:test (/ file ofile oline olist)

    (setq file (masi-get-reference))

    (if (findfile file)
    (progn

    (setq ofile (open file "r"))
    (while (setq oline (read-line ofile))
    (setq olist (cons oline olist)
    nlist (cons (substr oline 1 5) nlist)
    )

    );end of while
    (close ofile)
    )
    )

    (list (reverse nlist)(reverse olist))
    )



    "Michael Puckett" <Sp@mYourself.Sucka> wrote in message
    news:41c867cf$1_1@newsprd01...
    What about using vl-string-trim, vl-string-search etc. to suit ...

    (vl-string-trim " */t" "***122 LINE ONE")

    => "122 LINE ONE"

    (if
    (setq pos
    (vl-string-search
    " "
    (setq temp
    (vl-string-trim
    " */t"
    "**122 LINE ONE"
    )
    )
    )
    )
    (substr temp 1 pos)
    )

    => "122"

    Etc.

    "Rudy Tovar" <Rudy@CadentityNoSpam.com> wrote in message
    news:41c861bd$1_3@newsprd01...
    Before I actually get started, perhaps someone has already done this...
    it's
    actually a no brainer, but like to see if anyone has come up with a
    condensed version that's a bit more efficient...

    OK...

    First a text a file that contains...

    ****THIS COMMENT OR THAT****

    **122 LINE ONE
    **123 LINE TWO
    **124 LINE THREE

    ********************************

    Considering it may contain spaces and more comments, I'd like to be able
    to
    use vl-position to located number "122" in a list that I'll be creating
    of a
    file reference.

    Also, eliminate any spaces, or tabs when returning the reference number
    "LINE ITEM NOTE".

    list> = ("****THIS COMMENT OR THAT****" "" "**122 LINE ONE"
    ....etc.....)

    In the end I'd like to say (get-note "123" <list>) and all it returns is
    "LINE TWO" without any spaces or tabs in front of the note...

    I'd like to eliminate possibilities that someone may use spaces, tabs or
    both when writing the line item note.

    I know I could come up with a simple solution, but I'd like to see if
    someone may have a more efficient method, instead of having to compare
    each
    character in the LINE considering that the list could contain hundreds
    or
    items listed.

    Thank you for your comments





  5. #5
    Luis Esquivel Guest
    Hi Rudy,

    How many times are you going to open/read the file? or is just going to be a
    single call?

    (if (findfile file)
    (progn

    (setq ofile (open file "r"))
    (while (setq oline (read-line ofile))
    (setq olist (cons oline olist)
    nlist (cons (substr oline 1 5) nlist)
    )

    );end of while
    (close ofile)

  6. #6
    Rudy Tovar Guest
    One call in the beginning, it wouldn't be efficient to call the file several
    times.

    I gather the listing first then actually compare to a list of possible
    numbers.

    Although I only mention one number, it could be a list of random numbers.

    (list 122 123)
    read file
    return line for each number



    "Luis Esquivel" <nospam@address.withheld> wrote in message
    news:41c87038$1_2@newsprd01...
    Hi Rudy,

    How many times are you going to open/read the file? or is just going to be
    a
    single call?

    (if (findfile file)
    (progn

    (setq ofile (open file "r"))
    (while (setq oline (read-line ofile))
    (setq olist (cons oline olist)
    nlist (cons (substr oline 1 5) nlist)
    )

    );end of while
    (close ofile)

  7. #7
    Dick Coy Guest
    Can you store the text file in list format ie.
    ((1 . 1)(2 . "Solid Surface")(10 . "SS1")(20 . "Fossil")(30 . "Corian")(40 .
    "1")(50 . "Tops and splash"))

    ((1 . 2)(2 . "Solid Surface")(10 . "SS2")(20 . "Pompeii Red")(30 .
    "Corian")(40 . "1")(50 . "Lavatories"))

    ((1 . 3)(2 . "Solid Surface")(10 . "SS4")(20 . "Anthracite")(30 .
    "Corian")(40 . "1")(50 . "Base"))

    then search it like the acad database?



    "Rudy Tovar" <Rudy@CadentityNoSpam.com> wrote in message
    news:41c876be_2@newsprd01...
    One call in the beginning, it wouldn't be efficient to call the file
    several
    times.

    I gather the listing first then actually compare to a list of possible
    numbers.

    Although I only mention one number, it could be a list of random numbers.

    (list 122 123)
    read file
    return line for each number



    "Luis Esquivel" <nospam@address.withheld> wrote in message
    news:41c87038$1_2@newsprd01...
    Hi Rudy,

    How many times are you going to open/read the file? or is just going to
    be
    a
    single call?

    (if (findfile file)
    (progn

    (setq ofile (open file "r"))
    (while (setq oline (read-line ofile))
    (setq olist (cons oline olist)
    nlist (cons (substr oline 1 5) nlist)
    )

    );end of while
    (close ofile)



  8. #8
    BillZ Guest
    One possibility?

    R2005:

    (setq test '("****THIS COMMENT OR THAT****" " " "**122 LINE ONE" " " "" "**133 LINE FIVE" "" "" "**142 LINE SIX"))

    Just to make the list longer:

    (repeat 10 (setq test (append test test)))

    (length test) = 9216

    (defun get-note (itm) ;integer input
    (setq itm (itoa itm)
    searchitem (strcat "*" itm "*"))
    (car (apply 'append (mapcar '(lambda (x)(if (wcmatch x searchitem)(list (vl-position x test)))) test)))
    )
    2

    Command: timer
    Elapsed time: 0.015000 seconds



    Bill

  9. #9
    BillZ Guest
    Or:
    If you just want the item returned.

    Command:
    Command: (car (apply 'append (mapcar '(lambda (x)(if (wcmatch x "*122*")(list
    (vl-string-trim "*/t" x)))) test)))
    "122 LINE ONE"

    Command: (car (apply 'append (mapcar '(lambda (x)(if (wcmatch x "*133*")(list
    (vl-string-trim "*/t" x)))) test)))
    "133 LINE FIVE"

    Bill

  10. #10
    BillZ Guest
    Or maybe you could just filter the list with this once and do you vl-position after that?

    Bill

  11. #11
    Rudy Tovar Guest
    Thanks Bill for your comments in insight...

    "BillZ" <nospam@address.withheld> wrote in message
    news:86186.1103726704543.JavaMail.jive@jiveforum1. autodesk.com...
    Or maybe you could just filter the list with this once and do you
    vl-position after that?

    Bill

  12. #12
    Rudy Tovar Guest
    The file is external...

    "Dick Coy" <iwiest@attglobal.net> wrote in message
    news:41c96897$1_3@newsprd01...
    Can you store the text file in list format ie.
    ((1 . 1)(2 . "Solid Surface")(10 . "SS1")(20 . "Fossil")(30 . "Corian")(40
    .
    "1")(50 . "Tops and splash"))

    ((1 . 2)(2 . "Solid Surface")(10 . "SS2")(20 . "Pompeii Red")(30 .
    "Corian")(40 . "1")(50 . "Lavatories"))

    ((1 . 3)(2 . "Solid Surface")(10 . "SS4")(20 . "Anthracite")(30 .
    "Corian")(40 . "1")(50 . "Base"))

    then search it like the acad database?



    "Rudy Tovar" <Rudy@CadentityNoSpam.com> wrote in message
    news:41c876be_2@newsprd01...
    One call in the beginning, it wouldn't be efficient to call the file
    several
    times.

    I gather the listing first then actually compare to a list of possible
    numbers.

    Although I only mention one number, it could be a list of random numbers.

    (list 122 123)
    read file
    return line for each number



    "Luis Esquivel" <nospam@address.withheld> wrote in message
    news:41c87038$1_2@newsprd01...
    Hi Rudy,

    How many times are you going to open/read the file? or is just going to
    be
    a
    single call?

    (if (findfile file)
    (progn

    (setq ofile (open file "r"))
    (while (setq oline (read-line ofile))
    (setq olist (cons oline olist)
    nlist (cons (substr oline 1 5) nlist)
    )

    );end of while
    (close ofile)





Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other forums: Access Forum - Microsoft Office Forum - Exchange Server Forum