TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Andrea on May 27, 2010, 11:00:37 PM
-
Hi all..
I didn't see any think similar on the web...
so i've decided to post this code here.
The code below Show the last Monday Date.
If any of you have some diffrent way ...i'll be curius to see. :-)
(setq uMonth (menucmd "M=$(edtime,$(getvar,date),MO\)")
uDay (strcase (menucmd "M=$(edtime,$(getvar,date),DDD\)") t)
uDate (atoi (menucmd "M=$(edtime,$(getvar,date),DD\)"))
uYear (menucmd "M=$(edtime,$(getvar,date),YYYY\)")
)
(cond
((= uMonth "01")(setq uMonthday 31 pMonth "12"))
((= uMonth "02")(setq uMonthday 31 pMonth "01"))
((= uMonth "03")(setq uMonthday 28 pMonth "02"))
((= uMonth "04")(setq uMonthday 31 pMonth "03"))
((= uMonth "05")(setq uMonthday 30 pMonth "04"))
((= uMonth "06")(setq uMonthday 31 pMonth "05"))
((= uMonth "07")(setq uMonthday 30 pMonth "06"))
((= uMonth "08")(setq uMonthday 31 pMonth "07"))
((= uMonth "09")(setq uMonthday 31 pMonth "08"))
((= uMonth "10")(setq uMonthday 30 pMonth "09"))
((= uMonth "11")(setq uMonthday 31 pMonth "10"))
((= uMonth "12")(setq uMonthday 30 pMonth "11"))
)
(setq uDpos (vl-position uDay '("mon" "tue" "wed" "thu" "fri" "sat" "sun")))
(if (< (setq uDdiff (- uDate uDpos)) 0)
(setq uDate (+ uMonthday uDdiff)
uMonth pMonth)
(setq uDate (- uDate uDpos))
)
(alert (strcat "Monday the " (itoa uDate) " of " uMonth " Month " uYear))
-
how can there be a last monday of each week?
(not intending to be mean)
-
I think it's meant to go something like: "Today is Friday 28th May, so is in the week commencing Monday 24th May"
dJE
-
Nice idea, I suppose it could be made slightly more concise:
(defun c:Mon ( / uMonth uDay uDate uYear uMonthday pMonth uDpos uDdiff )
(setq uMonth (menucmd "M=$(edtime,$(getvar,date),MO\)")
uDay (strcase (menucmd "M=$(edtime,$(getvar,date),DDD\)") t)
uDate (atoi (menucmd "M=$(edtime,$(getvar,date),DD\)"))
uYear (menucmd "M=$(edtime,$(getvar,date),YYYY\)")
)
(setq uMonthday (nth (1+ (atoi uMonth)) '(31 31 28 31 30 31 30 31 31 30 31 30))
pMonth (itoa (1+ (rem (+ 10 (atoi uMonth)) 12))))
(setq uDpos (vl-position uDay '("mon" "tue" "wed" "thu" "fri" "sat" "sun")))
(if (< (setq uDdiff (- uDate uDpos)) 0)
(setq uDate (+ uMonthday uDdiff) uMonth pMonth)
(setq uDate (- uDate uDpos))
)
(alert (strcat "Monday the " (itoa uDate) " of " uMonth " Month " uYear))
(princ)
)
-
How about this :lol:
(alert
(menucmd
(strcat "M=$(edtime,"
(rtos
(- (getvar 'DATE)
(vl-position (strcase (menucmd "M=$(edtime,$(getvar,date),DDD\)") t)
'("mon" "tue" "wed" "thu" "fri" "sat" "sun")
)
)
2 15
)
",DD/MO/YYYY)"
)
)
)
-
wow Lee Nice ! :ugly:
-
(alert
(menucmd (strcat "M=$(edtime,"
(rtos (- (getvar 'DATE) (fix (rem (getvar 'DATE) 7))) 2 15)
",DD/MO/YYYY)"
)
)
)
-
(alert
(menucmd (strcat "M=$(edtime,"
(rtos (- (getvar 'DATE) (fix (rem (getvar 'DATE) 7))) 2 15)
",DD/MO/YYYY)"
)
)
)
OMG !! i'm out on this one..
nice coding Vovka !
-
(rtos (- (getvar 'DATE) (fix (rem (getvar 'DATE) 7))) 2 15)
Ah! I should have thought of that one - nice on VovKa you have trumped me yet again 8-)
-
(rtos (- (getvar 'DATE) (fix (rem (getvar 'DATE) 7))) 2 15)
Ah! I should have thought of that one - nice on VovKa you have trumped me yet again 8-)
(setq MyEgo (1+ MyEgo)) :)
-
I am home for day so I can test the the above code. What is the purpose or the final goal?
I am asking becuase if it is what I think it is, then I might have a use for something like this.
-
I'm guessing it might be useful when filling out a timesheet for week commencing... ;-)
-
I am home for day so I can test the the above code. What is the purpose or the final goal?
I am asking becuase if it is what I think it is, then I might have a use for something like this.
In Fact,...I have a prog who it write on TXT file all print data with:
date,loginname,papersize,paperstyle,printer name, number of copies,total area,...etc.
who can be imported in to an excel sheet and determine total cost by project, by date etc..
1 file by week, and the name need to be the Monday date. eg: 2010-05-31-Printdata.csv