Jump to content

"abc" to change "cba"


wimal

Recommended Posts

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"

Link to comment
Share on other sites

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 by pBe
Link to comment
Share on other sites

I think Tharwt's advise is best.

 

But I tried following way. can I go further or is this a stupid idea? :twisted:

(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 )

Link to comment
Share on other sites

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 )

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Finally I did that.

But it is not a proper way to do programming. :unsure:

 

(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 )

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.:)

Link to comment
Share on other sites

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 by pBe
retarded coding
Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...