wimal Posted December 10, 2011 Share Posted December 10, 2011 (strcat "a" "b" "c") = "abc" Is there any quick method to get "cba" Quote Link to comment Share on other sites More sharing options...
Tharwat Posted December 10, 2011 Share Posted December 10, 2011 check this out .... (vl-list->string (reverse (vl-string->list "abc"))) Quote Link to comment Share on other sites More sharing options...
wimal Posted December 10, 2011 Author Share Posted December 10, 2011 Actually my code is follows (setq tmk (strcat B1end", "B2end)) when I feed values I can get "14, 15" But some option I need it as "15, 14" But when I feed this to your code it produce "51 ,41" Quote Link to comment Share on other sites More sharing options...
pBe Posted December 10, 2011 Share Posted December 10, 2011 (edited) You may need to define a condition when to reverse and when to re-order something like this (defun RevOr (str) (if (vl-string-position (ascii ",") str) (apply 'strcat (mapcar '(lambda (j) (if (eq ', j) " , " (itoa j) ) ) (reverse (read (strcat "(" str ")"))) ) ) (vl-list->string (reverse (vl-string->list str))) ) ) (strcat B1end" , "B2end) "14 , 15" (REVOR (strcat B1end" , "B2end)) "15 , 14" (REVOR "pbe") "ebp" (REVOR "14 , 15 , 16 , 17") "17 , 16 , 15 , 14" Note the extra space at " , " instead of ", " Edited December 10, 2011 by pBe Quote Link to comment Share on other sites More sharing options...
Tharwat Posted December 10, 2011 Share Posted December 10, 2011 Just put B2end before B1end and there is no need to reverse any . Quote Link to comment Share on other sites More sharing options...
wimal Posted December 10, 2011 Author Share Posted December 10, 2011 I think Tharwt's advise is best. But I tried following way. can I go further or is this a stupid idea? (setq xx (list B1end", "B2end)) (setq yy (reverse xx)) But after that I need this yy to feed text command ??? can I convert this to feed to following code (command "text""j""ML" tt th 90 yy ) Quote Link to comment Share on other sites More sharing options...
Tharwat Posted December 10, 2011 Share Posted December 10, 2011 Why don't you show all your codes to give the chance for all to help you as best as it could be ? If you don't want to , just ask for a routine and we gonna write a complete one for you .( if it's possible ) Quote Link to comment Share on other sites More sharing options...
wimal Posted December 10, 2011 Author Share Posted December 10, 2011 No It is not necessary to waist your time. As you say I can write (setq tmk (strcat B1end", "B2end)) (setq tmk1 (strcat B2end", "B1end)) Quote Link to comment Share on other sites More sharing options...
ketxu Posted December 10, 2011 Share Posted December 10, 2011 You can use : (reverse (read (strcat "(" tmk ")"))) to get reverse a list (as pBe advise but only for your case) And use (vl-princ-to-string sth) to get string from list Quote Link to comment Share on other sites More sharing options...
wimal Posted December 11, 2011 Author Share Posted December 11, 2011 Finally I did that. But it is not a proper way to do programming. (reverse (read (strcat "(" tmk ")"))) (vl-princ-to-string sth) (setq xx (list B1end", "B2end)) (setq yy (reverse xx)) (setq yy1(vl-princ-to-string yy)) (setq yy2(substr yy1 2 8 ) (command "text""j""MR" tt th 90 yy2 ) Quote Link to comment Share on other sites More sharing options...
pBe Posted December 11, 2011 Share Posted December 11, 2011 Well, look wimal, you dont have to do that for every string, the sub will convert the string based on your condition Tell you what. give us the value for the following (for both conditions) sth tmk b1end b2end tt Quote Link to comment Share on other sites More sharing options...
wimal Posted December 11, 2011 Author Share Posted December 11, 2011 Actually I need to write bar marks in auto cad sheet. Barmarks are B1end & B2end (Eg. 14 & 15) always two digits I need to text insert like 14, 15 tt is insertion coordinates th is text height (setq tmk (strcat B1end", "B2end)) (command "text""j""MR" tt th 90 tmk ) =14, 15 ************************************************* But some time I need to put it as 15, 14 (setq xx (list B1end", "B2end)) (setq sth (reverse xx)) (setq yy1(vl-princ-to-string sth)) (setq yy2(substr yy1 2 8 ) (command "text""j""MR" tt th 90 yy2 ) =15, 14 ***************************************** But it is a long way I can put (setq tmk1 (strcat B2end", "B1end)) (command "text""j""MR" tt th 90 tmk1 ) =15, 14 ********************************************** I thought there may be one shot command in lisp to do this task. That is why I ask this question. But it is good ,because I learn very much . Thanks all. Quote Link to comment Share on other sites More sharing options...
pBe Posted December 11, 2011 Share Posted December 11, 2011 (edited) Edit: (command "text" "j" "MR" tt th 90 (if flg (strcat B1end ", " B2end)(strcat B2end ", " B1end))) where flg is a variable that dictates the sequence If you're routine will always have just that two variable and never a string of another format. stick with the line above I was made to believe from the first post that the string values varies from alpha to numeric strings hence the sub routine. we can write a sub to account for all conditions including multiple intger values of string Anyhoo. would there be by any chance you are passing a value from a Dialog box? Edited December 11, 2011 by pBe retarded coding Quote Link to comment Share on other sites More sharing options...
wimal Posted December 11, 2011 Author Share Posted December 11, 2011 Thank it works I used it following way:) (setq tmk (if flg (strcat B1end ", " B2end)(strcat B2end ", " B1end))) (command "text" "j" "MR" tt th 90 tmk) Quote Link to comment Share on other sites More sharing options...
SLW210 Posted December 12, 2011 Share Posted December 12, 2011 Please read CODE POSTING GUIDELINES. Quote Link to comment Share on other sites More sharing options...
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.