Splitted list to string

Splitted list to string

Anonymous
Not applicable
896 Views
4 Replies
Message 1 of 5

Splitted list to string

Anonymous
Not applicable

Hi!

I've a list of elements wich are actually a range in Excel, I mean: 

(setq i 1)
(setq my_rank (list 'A i ': 'B i))

I also have the GetCells.lsp function, and one of the arguments is the needed range. So, I must convert my_rank into a string. I've tried by using the strcat function but it doesn't work, I get a sort of error saying I'm giving a stringp...

Thank you so much

0 Likes
Accepted solutions (1)
897 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable

@Anonymous Try this?

_$ (setq i 1)
1
_$ (setq my_rank (list 'A i ': 'B i))
(A 1 : B 1)
_$ (vl-string-trim " ( ) " (vl-princ-to-string my_rank))
"A 1 : B 1"
_$ 
0 Likes
Message 3 of 5

doaiena
Collaborator
Collaborator

Here is what i came up with:

_$ (apply 'strcat (mapcar '(lambda (x) (if (vl-symbolp x) (vl-symbol-name x) (itoa x))) my_rank))
"A1:B1"
_$ 
Message 4 of 5

Satish_Rajdev
Advocate
Advocate

One more :

_$ (apply 'strcat (mapcar 'vl-princ-to-string my_rank))
"A1:B1"

Best Regards,
Satish Rajdev


REY Technologies | Linked IN | YouTube Channel


 

Message 5 of 5

Kent1Cooper
Consultant
Consultant
Accepted solution

@Anonymous wrote:

....

I've a list of elements wich are actually a range in Excel, I mean: 

(setq i 1)
(setq my_rank (list 'A i ': 'B i))

I also have the GetCells.lsp function, and one of the arguments is the needed range. So, I must convert my_rank into a string. ....


 

Dumb question, perhaps [I don't work with Excel files in connection with AutoCAD], but do you need the my_rank "middleman" variable at all?  Can you just build the string directly?

(strcat "A" (itoa i) ":B" (itoa i))
"A1:B1"

Kent Cooper, AIA
0 Likes