See the top rated post in this thread. Click here

Page 4 of 5 FirstFirst 12345 LastLast
Results 31 to 40 of 42

Thread: Custom Lisp Tracker

  1. #31
    I could stop if I wanted to msretenovic's Avatar
    Join Date
    2002-02
    Location
    Galloway, Oh
    Posts
    305
    Login to Give a bone
    0

    Wink Re: Custom Lisp Tracker

    Quote Originally Posted by fletch97 View Post
    Yes.

    I've tried creating the file straight from Excel, renaming a txt file, xls file, etc....
    (How did you create the cvs file?)

    Can't seem to get it to write to that file?......Any ideas?

    Thanks!
    A CVS file is an ASCII based file - meaning it is only text.

    Quote Originally Posted by Opie View Post
    Create a blank text file. If you want, I can add the option to create the file if it does not exist.
    As Opie pointed out, you only need a blank text file.

    Saving the file from Excel as an XLS file creates a binary file. This is why this does not work. However, creating a text file should work. As Opie pointed out, the routine can be modified to create the file if it does not exist. This would enable you to place some headers in the file before writing to it if you wanted.

    Anyway, hope that helps a little
    Michael K. Sretenovi?
    Most folks are about as happy as they make up their minds to be.
    -Abraham Lincoln (1809-1865)
    -16th president of The United States of America (1861 - 1865)

  2. #32
    I could stop if I wanted to
    Join Date
    2004-12
    Location
    California
    Posts
    283
    Login to Give a bone
    0

    Default Re: Custom Lisp Tracker

    Since I tried creating a txt file and it still didn't work for me, should we try having the lisp create the file instead?

  3. #33
    I could stop if I wanted to msretenovic's Avatar
    Join Date
    2002-02
    Location
    Galloway, Oh
    Posts
    305
    Login to Give a bone
    0

    Smile Re: Custom Lisp Tracker

    Quote Originally Posted by fletch97 View Post
    Since I tried creating a txt file and it still didn't work for me, should we try having the lisp create the file instead?
    Give this a try (comments in red, changes in bold red):
    Code:
    (defun lispWillStart (cmdData        lstCallbacks  /
                  dscFile        strLogFile      strCommandName
                  lstCommands          strDate
                  strDay        strDayText      strLogin
                  strMonth        strOutput      strTime
                  strVersion    strYear
                 )
      (setq    lstCommands '("C:EXP" "C:LYR" "C:PROBE" "C:LYRUP" "C:SPR")
        strLogFile     "C:/Lisp-Count.csv"
        strCommandName (strcase
                 (substr
                   (car lstCallbacks)
                   2
                   (1- (if (vl-string-search " " (car lstCallbacks))
                     (vl-string-search " " (car lstCallbacks))
                     (vl-string-search ")" (car lstCallbacks))
                       )
                   )
    
                 )
                   )
      )
    ;;only check for LISP
    (if (member strCommandName lstCommands)
        (progn
          ;;if the file is found...
          (if (findfile strLogFile)
            ;;...set strOutput to a zero-length string
            (setq strOutput "")
            ;;...else, set it to use a header
            (setq strOutput "LISP,Username,Date/Time,AutoCAD Version\n")
          )
          (setq strVersion (getAcadVersion)
            strDayText (menucmd "M=$(edtime, $(getvar,date),DDDD)")
            strTime    (menucmd "M=$(edtime, $(getvar,date),hh:mm:ss)")
            strMonth   (menucmd "M=$(edtime, $(getvar,date),MOnth)")
            strDay     (menucmd "M=$(edtime, $(getvar,date),DD)")
            strYear    (menucmd "M=$(edtime, $(getvar,date),yyyy)")
            strDate    (strcat strDayText       ", "         strMonth
                       " "     strDay       ", "         strYear
                       " "     strTime
                      )
            strLogin   (getvar "loginname")
            ;;append the information to the strOutput
            strOutput  (strcat strOutput
                       "\"" (car lstCallbacks)
                       "\",\""
                       strLogin
                       "\",\""
                       strDate
                       "\",\""
                       strVersion
                       "\""
                   )
          )
          (setq dscFile (open strLogFile "a"))
          (write-line strOutput dscFile)
          (close dscFile)
        )
      )
    )


    Also, one thing I just thought of, what would happen if the file were already open? If it is open with Notepad, everything would still be fine; Notepad does not mark a file as read only. However, if it is open in Excel, the file could not be written to.
    Michael K. Sretenovi?
    Most folks are about as happy as they make up their minds to be.
    -Abraham Lincoln (1809-1865)
    -16th president of The United States of America (1861 - 1865)

  4. #34
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    8,401
    Login to Give a bone
    0

    Default Re: Custom Lisp Tracker

    Quote Originally Posted by msretenovic View Post
    Also, one thing I just thought of, what would happen if the file were already open? If it is open with Notepad, everything would still be fine; Notepad does not mark a file as read only. However, if it is open in Excel, the file could not be written to.
    Then, I would suggest trying to open the file for write. If that fails, open and write to a temp file. Later, check to see if the temp file exists, if so, append that to the correct file and delete the temp file afterward.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  5. #35
    I could stop if I wanted to
    Join Date
    2004-12
    Location
    California
    Posts
    283
    Login to Give a bone
    0

    Default Re: Custom Lisp Tracker

    OK guys, so I decided to create this little lisp routine to test the csv file.....

    Code:
    (defun c:test ()
    
      (setq PR (open "c:/Lisp-Count.csv" "a"))
      (write-line "TESTING" PR)
      (close PR)
    
    (princ)
    )
    And it worked!!! It wrote to the csv file which says to me that the csv file is fine as well as the location. So now it has to be something in the lisp that is not writing correctly to the file?

    Any ideas? Does this help narrow the problem down?

  6. #36
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    8,401
    Login to Give a bone
    0

    Default Re: Custom Lisp Tracker

    Are you using the VLIDE to test your code? Place a break point at a point near the beginning of this routine. Then run one of your custom routines. It should trigger your reactor and hit the break point. You can then cycle through the code one step at a time to see what is happening.

    Try that and let us know what you find out.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  7. #37
    I could stop if I wanted to
    Join Date
    2004-12
    Location
    California
    Posts
    283
    Login to Give a bone
    0

    Default Re: Custom Lisp Tracker

    Never used VLIDE before, kind of old school with notepad for my lisp.

    I'll try it but I may not be able to run your suggestion Opie since it's new to me.

  8. #38
    I could stop if I wanted to
    Join Date
    2004-12
    Location
    California
    Posts
    283
    Login to Give a bone
    0

    Default Re: Custom Lisp Tracker

    I opened the lisp with VLIDE, how do I insert a break point and test?

  9. #39
    I could stop if I wanted to msretenovic's Avatar
    Join Date
    2002-02
    Location
    Galloway, Oh
    Posts
    305
    Login to Give a bone
    0

    Wink Re: Custom Lisp Tracker

    Quote Originally Posted by fletch97 View Post
    I opened the lisp with VLIDE, how do I insert a break point and test?
    To set a breakpoint, place your cursor next to a paren and press the F9 key.
    Michael K. Sretenovi?
    Most folks are about as happy as they make up their minds to be.
    -Abraham Lincoln (1809-1865)
    -16th president of The United States of America (1861 - 1865)

  10. #40
    I could stop if I wanted to
    Join Date
    2004-12
    Location
    California
    Posts
    283
    Login to Give a bone
    0

    Default Re: Custom Lisp Tracker

    Great.....so now what? How can I test like Opie suggested?

    Sorry, never used VLIDE before.

Page 4 of 5 FirstFirst 12345 LastLast

Similar Threads

  1. Replies: 0
    Last Post: 2015-08-07, 03:58 PM
  2. Custom LISP Routine please!
    By Crask422 in forum AutoLISP
    Replies: 1
    Last Post: 2015-02-08, 06:24 PM
  3. Get SSM Custom Property Via LISP
    By BlackBox in forum AutoLISP
    Replies: 3
    Last Post: 2010-07-20, 08:30 PM
  4. Custom Fypon lisp
    By BCrouse in forum AutoLISP
    Replies: 3
    Last Post: 2005-08-08, 07:07 PM

Posting Permissions

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