See if this new code works.
(defun c:test
(/ blk lst val HL1 HL2 HL3 SL1 SL2 SL3 tlst mtext
) (setq lst
(vlax-invoke blk 'getdynamicblockproperties
)) ;list dynamic properties ((eq (vla
-get
-propertyname val
) "HL1") (setq HL1
(vla
-get val 'value
)) )
((eq (vla
-get
-propertyname val
) "HL2") (setq HL2
(vla
-get val 'value
)) )
((eq (vla
-get
-propertyname val
) "HL3") (setq HL3
(vla
-get val 'value
)) )
((eq (vla
-get
-propertyname val
) "SL1") (setq SL1
(vla
-get val 'value
)) )
((eq (vla
-get
-propertyname val
) "SL2") (setq SL2
(vla
-get val 'value
)) )
((eq (vla
-get
-propertyname val
) "SL3") (setq SL3
(vla
-get val 'value
)) )
)
)
;(setq HL1 1000.0 HL2 0 HL3 2000 SL1 "P" SL2 "CIP" SL3 "R") ;for testing erase if you want
)
)
)
(setq mtext
(car lst
)) ;builds a string from the list generated above with \\P inbetween them )
(command "_Mleader" pause pause mtext
) )
(prompt "\nNot a Block or Missing one of the HL Values") )
)
thought itoa would act like (fix real number) guess not.
The not really a benefit its just needed because we are processing the data differently. I'm using one list to store all three strings. its basically saying for each item in lst join them together into one big string but put a "//P" between them.
the code would be the same if the list was 30 strings.
Since your using three variables using (strcat a b c) would error if any of those are nil. and since you wanted to exclude any that where set to 0 you would have to make a cond to test all variables. then use the right strcat to add them together.
if you where to add more variables the conditional would grow.
Also since you have the newline call already added into the hl2 string if hl1=0 the mtext created would have a blank first line then hl2.