Jump to content

Recommended Posts

Posted (edited)

I am going around in circle and not sure why. I have a Mtext  a simple 3 line Mtext 

 

(setq txt "Abcdef\\Pghijk\\Plmnop")

desired text for Excel a multi line cell

"Abcdef\nghijk\nlmnop"

thought something like this should work. Tried all sorts of combinations. Note a dbl \\ will leave the P behind but get multi lines.

(setq txt  (vl-string-translate "\\P" "\n" txt))

 

I have all the other code done putting all the object values int Excel cells. Think Dataextract.

Edited by BIGAL
Posted
(defun c:t1 ( / txt1 delimiter txt2 )
  (setq txt1 "Abcdef\\Pghijk\\Plmnop")
  (setq delimiter "\\P")
  (setq txt2 (pjk-Strparse txt1 delimiter))
  (princ (strcat "\ntxt2 = " (vl-prin1-to-string txt2)))
  (princ)
)
  
;;; https://www.cadtutor.net/forum/topic/95913-replace-p-in-a-variable/

;|==============================================================================
  Function Name: (pjk-StrParse)
  Arguments:
     str = String; String to process
     del = String; Delimiter to separate the string
  Usage: (pjk-StrParse <string> <delimter>)
  Returns: List; A list of strings
  Description:
     Separates a string into a list of strings using a
     specified delimiter string; uses recursion.
================================================================================|;
(defun pjk-StrParse (str del / pos)
  (if (and str del)
     (if (setq pos (vl-string-search del str))
       (cons (substr str 1 pos) (pjk-StrParse (substr str (+ pos 1 (strlen del))) del))
       (list str)
     )
  )
) ;; End Function (pjk-StrParse)

 

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