here's one way to get the suffix
Code:(setq suffix (chr (last (vl-string->list age)))) (cond ((eq suffix "1") (setq suffix "st")) ((eq suffix "2") (setq suffix "nd")) ((eq suffix "3") (setq suffix "rd")) ( T (setq suffix "th")) )
Registered forum members do not see this ad.
Hi together,
I would like to play a trick on my draftsman colleagues and I needed some help.
...feel free to improve my poor coding...
Thank you in advanced !!!Code:(defun c:HappyBirthday (/ UserName User1 B-Day_Date R-age age ry) (if ;list of users for the pop-ups (setq UserName (strcase(getvar 'loginname))) (progn (cond ; User Name User Birthday retirement age ((equal UserName "MH019") (setq User1 "Michael" B-Day_Date "19991003" R-age 67)) ((equal UserName "MH019") (setq User1 "Michael" B-Day_Date "20180109" R-age 67)) ((equal UserName "MH019") (setq User1 "Michael" B-Day_Date "20180110" R-age 67)) (T (princ "\n\nSorry, User not listed !!!")) );_cond end );_progn end );_if end (setq age (itoa (- (atoi (substr (rtos (fix (getvar 'CDATE))) 1 4)) (atoi (substr B-Day_Date 1 4)) ) ));calculating the age of the user (setq ry (itoa (- R-age (atoi age))));remaining years until retirement (alert (strcat "Hello " User1 "!" "\n\nHerzlichen Glückwunsch zum " age ". Geburtstag !!!" "\n\nCongratulations on your " age "st/nd/rd/ th birthday !!!" ;here I need some help for the e.g. 21st, 22nd, 23rd, 24th. "\n\n\n\nVon jetzt an, sind es nur noch " ry " Jahre bis zur Rente \n... Also hau rein ... :-)" "\n\nFrom now on, there are only " ry " years left to retirement \n... so get in there ... :-)" "\n\n\nKeyuser Michael" ) ) (princ) ) ;original code from 06.01.2011/Lee Mac changed on my needs ;http://www.cadtutor.net/forum/showthread.php?55800-Differences-in-exiting-AutoCAD&p=378358&viewfull=1#post378358 (if (not (and (setq date (getenv "OnceAYear")) (< (fix (getvar 'CDATE)) (atoi date)) );_end and );_end not (progn (c:HappyBirthday) (setenv "OnceAYear" (itoa (+ 10000 (fix (getvar 'CDATE))))) ;stored in windows registry [HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\R19.1\ACAD-D004:409\FixedProfile\General] );_end progn );_end if (princ)
kind regards
Bluebird1973
here's one way to get the suffix
Code:(setq suffix (chr (last (vl-string->list age)))) (cond ((eq suffix "1") (setq suffix "st")) ((eq suffix "2") (setq suffix "nd")) ((eq suffix "3") (setq suffix "rd")) ( T (setq suffix "th")) )
Lee Mac Programming • Twitter • Exchange App Store • Dropbox (500MB free)
With Mathematics there is the possibility of perfect rigour, so why settle for less?
How about something like this?Copy the above into your acaddoc.lspCode:( (lambda ( lst / age itm ord ret ) (defun ord ( n ) (cond ((< 10 (rem n 100) 14) "th") ((nth (rem n 10) '(nil "st" "nd" "rd"))) ("th"))) (cond ( (null (setq itm (assoc (strcase (getvar 'loginname)) lst))) (princ "\nSorry, user not listed!") ) ( (zerop (rem (setq age (- (fix (getvar 'cdate)) (caddr itm))) 10000)) (setq age (/ age 10000) ret (- (cadddr itm) age) ) (alert (strcat "Hello " (cadr itm) "!" "\n\nHerzlichen Glückwunsch zum " (itoa age) ". Geburtstag !!!" "\n\nCongratulations on your " (itoa age) (ord age) " Birthday !!!" "\n\n\n\nVon jetzt an, sind es nur noch " (itoa ret) " Jahre bis zur Rente \n... Also hau rein ... :-)" "\n\nFrom now on, there are only " (itoa ret) " years left to retirement \n... so get in there ... :-)" "\n\n\nKeyuser Michael" ) ) ) ) (princ) ) '( ("MH019" "Michael" 19991003 67) ("MH019" "Michael" 20180109 67) ("MH019" "Michael" 20180110 67) ) )![]()
Lee Mac Programming • Twitter • Exchange App Store • Dropbox (500MB free)
With Mathematics there is the possibility of perfect rigour, so why settle for less?
This made me wonder, why not write some generic function that uses one of the arguments:
'(day week month year)
Code:(defun RunOnceA ( sym func ) ...) (RunOnceA 'week '(lambda ( / ) <bla-bla>) )
Hellooooo
make sure speaker is on
Code:(defun SpeakSapi ( s / sapi ) (if (eq (type s) 'STR) (progn (setq sapi (vlax-create-object "Sapi.SpVoice")) (vlax-put sapi 'SynchronousSpeakTimeout 1) (vlax-invoke-method sapi 'WaitUntilDone 0) (vlax-invoke sapi "Speak" s 0) (vlax-release-object sapi) ) ) ) (speaksapi "please remain seated during your Autocad session do not leave work area") (setq x 24) (setq ans (strcat "alan is " (rtos x 2 0))) (speaksapi ans)
A man who never made mistakes never made anything
Hi together,
Thanks to everyone, I appreciate that very much !
@ Lee Mac
I didn't get your code to run. I put it on my acaddoc.lsp but nothing happens.
What I'm doing wrong?
... and I have problems to understand what's going on. Could you please add some comments/explanations for me?
@BIGAL
This is a funny one.... but we have no speakers ...
Lee Mac Programming • Twitter • Exchange App Store • Dropbox (500MB free)
With Mathematics there is the possibility of perfect rigour, so why settle for less?
Registered forum members do not see this ad.
Thank you Lee Mac !!!
now I got it. ...but didn't understand the code
is there a way to not pank my draftsman the whole day?
... 3 or 4 times would be enough ...
Bookmarks