hosyn Posted July 7, 2013 Posted July 7, 2013 (edited) What's the difference between common lisp and autolisp?? i have this code common lisp for reverse text: "hello world" ----> "dlrow olleh" the code is: (defun C:reverse() (vl-list->string (reverse (vl-string->list str)) (SETQ MMT (getstring()) (REVERSE(MMT)) ) but dont work:( Edited July 7, 2013 by hosyn Quote
Tharwat Posted July 7, 2013 Posted July 7, 2013 The first thing that you have used the function reverse as a name of function which is can not perform as sub-function since that it is a built-in function , secondly your function is correct but with a missing paren to be completed . try . (defun rev (str) (vl-list->string (reverse (vl-string->list str))) ) Quote
hosyn Posted July 7, 2013 Author Posted July 7, 2013 How can that code work for reverse : "hello world" ----> "dlrow olleh" Quote
Tharwat Posted July 7, 2013 Posted July 7, 2013 Why did you modify your first post after my reply ? How can that code work for reverse :"hello world" ----> "dlrow olleh" Huh ؟؟؟ Quote
hosyn Posted July 8, 2013 Author Posted July 8, 2013 dear tharwat I try the fierst one and dont have good resault--i thoght that the first code in begun have problem:cry:. i correct the prantess as you mentioned but unfortunately dont get result. Quote
MSasu Posted July 8, 2013 Posted July 8, 2013 Hosyn, to fix your code: (defun C:ReverseString( / ) (if (SETQ MMT (getstring "\nInput string to be reversed: ")) (print (vl-list->string (reverse (vl-string->list MMT)))) ) (princ) ) Quote
Lee Mac Posted July 8, 2013 Posted July 8, 2013 Alternatively, using only Vanilla AutoLISP: (defun reversestring ( str / lst ) (repeat (strlen str) (setq lst (cons (substr str 1 1) lst) str (substr str 2) ) ) (apply 'strcat lst) ) _$ (reversestring "Hello World!") "!dlroW olleH" Quote
LibertyOne Posted July 8, 2013 Posted July 8, 2013 Stange that the code in VisualLisp has more characters (therefore longer) than... (defun C:ReverseString( / ) (if (SETQ MMT (getstring "\nInput string to be reversed: ")) (print (vl-list->string (reverse (vl-string->list MMT)))) ) (princ) ) ...the vanilla AutoLisp code. (defun reversestring ( str / lst ) (repeat (strlen str) (setq lst (cons (substr str 1 1) lst) str (substr str 2) ) ) (apply 'strcat lst) ) Quote
MSasu Posted July 8, 2013 Posted July 8, 2013 LibertyOne, the VLISP code you used in comparison contains in fact extra statements to allow for testing. Instead should check against this: (defun ReverseString( str / ) (vl-list->string (reverse (vl-string->list str))) ) Quote
dong95 Posted July 8, 2013 Posted July 8, 2013 How about using system variable Mirrtext set to 1. Quote
Lee Mac Posted July 8, 2013 Posted July 8, 2013 Or, (defun c:revtxt ( / i s ) (if (setq s (ssget "_:L" '((0 . "TEXT") (-4 . "<NOT") (-4 . "&=") (71 . 2) (-4 . "NOT>")))) (repeat (setq i (sslength s)) (vla-put-backward (vlax-ename->vla-object (ssname s (setq i (1- i)))) :vlax-true) ) ) (princ) ) (vl-load-com) (princ) Quote
MSasu Posted July 9, 2013 Posted July 9, 2013 How about using system variable Mirrtext set to 1. Dong95, I believe that the OP was looking to programatically reverse a string stored into a variable (that it, invert the order of its characters), not to show in mirror a text entity in editor; example: "MIRRTEXT" --> "TXETRRIM" Quote
cuasuavdd Posted January 23, 2014 Posted January 23, 2014 Can you all make a lisp with select all txt mtxt and reverse value on that in a drawing? Quote
MSasu Posted January 23, 2014 Posted January 23, 2014 Cuasuavdd, a routine to batch reverse all TEXT type labels in the drawing using one of the above proposed solutions will be quite easy. However, for MTEXT will be a quite laborious task since for those the formatting is retained as control strings along text value, so will need to be skipped at reverse. Also, welcome to the Forum! 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.