Lee Mac Posted February 10, 2012 Posted February 10, 2012 Since you're in turbo mode.. write one for (vlax-get-or-create-object "VBScript.RegExp") for the fun of it Just for the fun of it (defun test ( str / regex ) (if (setq regex (vlax-get-or-create-object "VBScript.RegExp")) (progn (setq str (vl-catch-all-apply (function (lambda ( ) (vlax-put-property regex 'pattern "^(.)[^.]*\\.(.*)$") (vlax-invoke-method regex 'replace str "$1.$2") ) ) ) ) (vlax-release-object regex) (if (null (vl-catch-all-error-p str)) (strcase str) ) ) ) ) (vl-load-com) _$ (test "Daniel.Williams") "D.WILLIAMS" Quote
pBe Posted February 10, 2012 Posted February 10, 2012 Just for the fun of it _$ (test "Daniel.Williams") "D.WILLIAMS" Cool beans Thanks Lee Cheers Quote
dannywi77iams Posted February 13, 2012 Author Posted February 13, 2012 Here is my finished code for now. I'll may end up changing it someday. (defun c:l2t () (setq usernm (strcase (getvar "Loginname")));"Daniel.Williams" (setq fstin (strcat (substr usernm 1 1)); Split usernm to find first name inital "D" surnm (last (fnsplitl usernm)); Split usernm to find surname ".Williams" surin (strcat (substr surnm 1 2))); Splits the surnm to find the surname inital ".W" ;;; ******** Create names: ******** (setq tilnm (strcat fstin surnm)); Create title name ("D.WILLIAMS") (setq revin (strcat fstin surin ".")); Create inital name ("D.W.") ); end Quote
MSasu Posted February 13, 2012 Posted February 13, 2012 You may define the variables that aren't needed outside your routine as local to avoid interference with other codes: (defun c:l2t ( / [color=blue]usernm fstin surnm surin[/color] ) (setq usernm (strcase (getvar "Loginname")));"Daniel.Williams" (setq fstin (strcat (substr usernm 1 1)); Split usernm to find first name inital "D" surnm (last (fnsplitl usernm)); Split usernm to find surname ".Williams" surin (strcat (substr surnm 1 2))); Splits the surnm to find the surname inital ".W" ;;; ******** Create names: ******** (setq tilnm (strcat fstin surnm)); Create title name ("D.WILLIAMS") (setq revin (strcat fstin surin ".")); Create inital name ("D.W.") ); end Are you going to use this on command prompt or inside an AutoLISP routine? For the second case I suggest to define a function instead of a command. Regards, Mircea Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.