MJLM Posted February 6, 2016 Posted February 6, 2016 I m having this issue. I have some text that I want to have aligned. I m not talking about text in the model, I only talk about text printed (via prompt command) in the text window. I m having troubles to align it. Take a look at the following I want to have the results of feet aligned. I am using the following to print the text using the \t. (prompt (strcat "Minimum vertical change: " (rtos minz 2 2) " m\t(" (rtos (m2ft minz) 2 2) " ft)\n")) (prompt (strcat "Maximum vertical change: " (rtos maxz 2 2) " m\t(" (rtos (m2ft maxz) 2 2) " ft)\n\n")) (prompt (strcat "Highest elevation of system: " (rtos highz 2 2) " m\t(" (rtos (m2ft highz) 2 2) " ft)\n")) (prompt (strcat "Minimum elevation of system: " (rtos lowz 2 2) " m\t(" (rtos (m2ft lowz) 2 2) " ft)\n\n")) I was under the impression that the \t switch will tab all the lines under the same alignment. But regardless of many \t in a row I use, all are pushed equally unaligned. Do I miss something simple/basic here or do I need to elaborate with some custom-made code to do this? Thank you. Quote
Tharwat Posted February 6, 2016 Posted February 6, 2016 Hi, It would be a good presentation if you write a custom function that deduct the length of chars in the two strings eg (0.25m and (0.82 ft)) then add empty spaces as a gap between the two text strings. Quote
Tharwat Posted February 6, 2016 Posted February 6, 2016 e.g: (defun _Add:gaps (st1 st2 len / st) ;; Tharwat 06.02.2016 ;; (repeat (- len (+ (strlen st1) (strlen st2))) (setq st (cons (chr 32) st)) ) (strcat st1 (apply 'strcat st) st2) ) Usage of function: (_Add:gaps (rtos minz 2 2) (strcat (rtos (m2ft minz) 2 2) " ft") 20) Quote
MJLM Posted February 6, 2016 Author Posted February 6, 2016 yes I know but I find it boring I though there was something simple. In MC Word for instance this does not happen. Anyway thanks. Quote
Tharwat Posted February 6, 2016 Posted February 6, 2016 (edited) I guess you did not see the codes when you replied to my first reply. Anyway here is another one if you want the second value aligned NOTE: Keep the length number static because this is the secret of the function. (defun _Add:gaps (st1 st2 len / st) ;; Tharwat 06.02.2016 ;; (repeat (- len (strlen st1)) (setq st (cons (chr 32) st)) ) (strcat st1 (apply 'strcat st) st2) ) Edited February 6, 2016 by Tharwat Quote
David Bethel Posted February 6, 2016 Posted February 6, 2016 The tab character has always been flakey Try this code : (textpage) (princ "\n1\t234567890") (princ "\n12\t34567890") (princ "\n123\t4567890") (princ "\n1234\t567890") (princ "\n12345\t67890") (princ "\n123456\t7890") (princ "\n1234567\t890") (princ "\n12345678\t90") (princ "\n123456789\t0") The image attached is from various ACAD releases using the same code. R12 -> 2012 Quote
Tharwat Posted February 6, 2016 Posted February 6, 2016 Thank you. It works fine. You're welcome. Quote
BIGAL Posted February 6, 2016 Posted February 6, 2016 My version of Davids tested on 2013, side note what about a DCL ? Something to think about tabs stops are I think 8 characters wide so if you have text 9 characters wide you may need \t\t as per second code example. (Alert (strcat "\n1\t234567890" "\n12\t34567890" "\n123\t4567890" "\n1234\t567890" "\n12345\t67890" "\n123456\t7890" "\n1234567\t890" "\n12345678\t90" "\n123456789\t0") ) (Alert (strcat "\n1\t234567890" "\n12\t\t34567890" "\n123\t\t4567890" "\n1234\t\t567890" "\n12345\t\t\t\t67890" "\n123456\t\t\t\t7890" "\n1234567\t\t\t\t890" "\n12345678\t\t\t\t\t\t90" "\n123456789\t\t\t0") ) Quote
BIGAL Posted February 6, 2016 Posted February 6, 2016 Ok had a play and found what I thought have a look at this and you can see the 0.0 on last line is pushed over you have 1 character to many so hit a tab spot try "Min." or "Elev." (alert (strcat "Minimum vertical change: " "0.25 m " "\t" (chr 40) "0.82 ft" (chr 41) "\nMaximum vertical change: " "5.00 m" "\t" (chr 40) "16.4 ft" (chr 41) "\n\n" "\nHighest elevation of system: " "6.00 m" "\t" (CHR 40) "19.69 ft" (chr 41) "\nMinimum elevation of system: " "0.0" "\t" (chr 40) "0.00 ft" (chr 41) ) 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.