replacement for dos_filedate

replacement for dos_filedate

HE-MJJ
Advocate Advocate
1,800件の閲覧回数
25件の返信
メッセージ1/26

replacement for dos_filedate

HE-MJJ
Advocate
Advocate

I'm trying find a replacement for dos_filedate.

 

I thought by using vl-file-systime, but vl-file-systime apparently does not return a value of a file that is opened which dos_filedate does. As you can see in results below:

 

_$ (vl-file-systime "H:\\0000\\0000\\Tekeningen\\BT\\0000_BT-BB-022A.dwg")
nil
_$ (vl-file-systime "H:\\0000\\0000\\Tekeningen\\BT\\0000_BT-BB-022.dwg")
(2024 3 5 15 12 31 56 0)
_$ (dos_filedate "H:\\0000\\0000\\Tekeningen\\BT\\0000_BT-BB-022A.dwg")
(("0000_BT-BB-022A.dwg" . 2.02404e+07))
_$

 

Does anyone know a working alternative for dos_filedate to obtain the date of an opened drawing?

0 件のいいね
1,801件の閲覧回数
25件の返信
返信 (25)
メッセージ2/26

paullimapa
Mentor
Mentor

Perhaps try code on this thread


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 件のいいね
メッセージ3/26

EnM4st3r
Advocate
Advocate

try this:

  (if (not jtod) (load "Julian.lsp"))
  (jtod (getvar "tdupdate"))
0 件のいいね
メッセージ4/26

HE-MJJ
Advocate
Advocate

Thanks. Not sure if I already tried this. I need it to work under AutoCAD LT. I will try to figure it out...

0 件のいいね
メッセージ5/26

HE-MJJ
Advocate
Advocate

Thanks. Not sure if I already tried this. I need it to work under AutoCAD LT. I will try to figure it out...

0 件のいいね
メッセージ6/26

paullimapa
Mentor
Mentor

Then it won’t work since LT lisp doesn’t support this function  vlax-create-object which is required to run that code


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 件のいいね
メッセージ7/26

EnM4st3r
Advocate
Advocate

julain.lsp is from express tools. it does not use vlax-create-object so it should work. Though idk if you have access to them

0 件のいいね
メッセージ8/26

HE-MJJ
Advocate
Advocate

That is too bad. I like to think in possibilities ; )

 

0 件のいいね
メッセージ9/26

paullimapa
Mentor
Mentor

Unfortunately no express tools for LT either 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 件のいいね
メッセージ10/26

HE-MJJ
Advocate
Advocate

I have Julian.lsp but afaik it cannot be use to obtain the date of a file. Correct me if I'm wrong.

0 件のいいね
メッセージ11/26

EnM4st3r
Advocate
Advocate

you can use it to convert the time you get in Juilan format for example (getvar "TDUPDATE") wich gives you the last updated time.
Watch my first answer.

0 件のいいね
メッセージ12/26

EnM4st3r
Advocate
Advocate

i mean its just basic calculations. Though im not sure if we are allowed to just post that code.

0 件のいいね
メッセージ13/26

EnM4st3r
Advocate
Advocate

here try this. Since you said you have Julian.lsp it should work.

(defun c:timetest (/ date dateStr)
  (if (not jtod) (load "Julian.lsp"))
  (CurDate (jtod (getvar "TDUPDATE")) nil)
)

; Returns or outputs the current date and time
; time = coded decimal time format (like you get from CDATE)
; bOutput = T - Output the string to the Command prompt
; bOutput = nil - Return a string in the MM/DD/YYYY  HH:MM:SS format
; Usage: (CurDate T)
; Usage: (CurDate nil)

(defun CurDate (time bOuput / date_val YYYY M D HH MM SS)
  ; Get the current date/time
  (setq date_val (rtos time 2 6))

  ; Break up the string into its separate date and time parts
  (setq YYYY (substr date_val 1 4)
        M    (substr date_val 5 2)
        D    (substr date_val 7 2)
        HH   (substr date_val 10 2)
        MM   (substr date_val 12 2)
        SS   (substr date_val 14 2)
  )

  ; Output the current date and time to the Command
  ; prompt or return the formatted output as a string
  (if bOuput
    (progn
      (prompt (strcat "\nDate: " M "/" D "/" YYYY
                      "\nTime: " HH ":" MM ":" SS
              )
      )
      (princ)
    )
    (strcat M "/" D "/" YYYY "  " HH ":" MM ":" SS)
  )
)
0 件のいいね
メッセージ14/26

HE-MJJ
Advocate
Advocate

Ah! I see what you mean. Maybe I can use this in a different approach. Thanks.

0 件のいいね
メッセージ15/26

HE-MJJ
Advocate
Advocate

Hi,

 

I'm picking up on this subject again and I'm running into some issues...

 

For example: I have this file:

HEMJJ_2-1717578258843.png

(setq fnm-d (vl-file-systime "H:\\0000\\0000\\Tekeningen\\BT\\0000_BT-BB-022.dwg"))

Results in: (2024 3 5 15 12 31 56 0)

Hours is 12 and according to above properties it is 11. So I guess daylight savings time is not taken into account.

But that's not so much the problem. The date is more important for me.

 

(dtoj 20240315) results in: 2.46038e+06 But reversed: (jtod 2.46038e+06) results in 2.02403e+07

Why is this? Do I use wrong input?

 

0 件のいいね
メッセージ16/26

HE-MJJ
Advocate
Advocate

CDATE = 20240605.11173200 (read only)


_$ (dtoj 20240605.11173200)
2.46047e+06
_$ (jtod 2.46047e+06)
2.02406e+07

Not? 20240605.11173200

 

 

0 件のいいね
メッセージ17/26

EnM4st3r
Advocate
Advocate

(dtoj 20240315) results in: 2.46038e+06 But reversed: (jtod 2.46038e+06) results in 2.02403e+07

Why is this? Do I use wrong input?

 


this is just the written output in the commandline, the value is actually the same.

you can try this for example and will see its equal:

(setq cdate 20240605.11173200)
(equal cdate (jtod (dtoj cdate)) 0.001)

 

0 件のいいね
メッセージ18/26

EnM4st3r
Advocate
Advocate

so if you print it to the commandline using for example rtos it will give out the actual result with your given precision

(rtos (jtod (dtoj 20240315)) 2 6)

 

0 件のいいね
メッセージ19/26

HE-MJJ
Advocate
Advocate

I seem to be almost there...

 

This is my replacement for dos_filedate so far:

 

(defun dos-filedate (fnm / fnm-d fnm-d-j )
(if (setq fnm-d (vl-file-systime fnm))
(progn
(setq fnm-d-j (dtoj (atoi (strcat (rtos (nth 0 fnm-d) 2 0) (strnr (rtos (nth 1 fnm-d) 2 0) 2) (strnr (rtos (nth 3 fnm-d) 2 0) 2))))) ; Check: (rtos (jtod fnm-d-j) 2 6)
(setq fnm (list (cons (strcat (nth 2 (dos-splitpath fnm)) (nth 3 (dos-splitpath fnm))) fnm-d-j)))
)
(if (= (strcase (strcat (getvar "dwgprefix") (getvar "dwgname"))) (strcase fnm)) ; Bij dit geopende bestand
(progn
(setq fnm-d-j (getvar "tdupdate")) ; Check: (rtos (jtod fnm-d-j) 2 6)
(setq fnm (list (cons (strcat (nth 2 (dos-splitpath fnm)) (nth 3 (dos-splitpath fnm))) fnm-d-j)))
)
)
)
fnm
)

 

If I check my code by replacing - for _ in dos_filedate

 

; form dos_filedate loaded * original doslib command *
_$
_1_$

(("0000_BT-BB-022.dwg" . 2.02403e+07))
_1_$

(("0000_BT-BB-022A.dwg" . 2.02404e+07))
_1_$
_$

; form dos-filedate loaded
_$
_1_$

(("0000_BT-BB-022.DWG" . 2.46038e+06))
_1_$

(("0000_BT-BB-022A.DWG" . 2.46041e+06))
_1_$
_$

 

This results in these different dates:

HEMJJ_0-1717664936729.png

Can you see where I'm ging wrong in the code?

 

(strnr is used to add 0 when strlen is 1)

 

 

0 件のいいね
メッセージ20/26

HE-MJJ
Advocate
Advocate

Almost got it:

Corrected the code and this is now correct:

 

HEMJJ_0-1717666713663.png

Exept no time. What is the cause of that?

 

0 件のいいね