Kreaten_vhar Posted October 10, 2022 Posted October 10, 2022 How's it going everybody? Today I write because I have been banging my head against a wall trying to find out why I can't write the output of a vl-list->string to a text file. I have a list that's equal to (0 1 2), I run that through vl-list->string and get the ASCII codes as a string in the form of "\000\001\002" as the output. So I then save that string to a variable, say, VariableWithString. All good so far. When I attempt to write this string of ASCII codes to a file using (write-line VariableWithString File) what gets written to the file is just a blank new-line (other write-line statements get written fine.) Not so good now, but I figure I could fix it. Well I can't really figure it out At first I figured there was some escape character shenanigans going on, so I tried to append extra \'s to the string. vl-string-translate wasn't able to pick up on the existing \'s however. I have made some progress, such as noticing that a statement such as (vl-string-translate "0" "/0" VariableWithString) will actually replace the \000 with just a plain 0, but this solution makes later coding a bit more difficult/tedious cause the initial list can vary in size quite a bit. I'd very much like to be able to get the exact string, that whole "\000\001\002" written to the file so I can later just do a quick vl-string->list to get my list back, or at the least a version of the string that I could easily restore to the proper form to get my list back. And I figure it's worth mentioning I'm on BricsCAD Thanks ahead of time all for any help/insight you can offer! Quote
mhupp Posted October 10, 2022 Posted October 10, 2022 (edited) That is a list of integers they need to be converted to strings to be written to a file. (foreach x lst (if (numberp x) (writeline (rtos x 2 0)) (writeline x) ) ) Edited October 10, 2022 by mhupp number checking 1 Quote
Kreaten_vhar Posted October 10, 2022 Author Posted October 10, 2022 Oh hey, yeah, that actually works quite well. I was definitely too deep into the vl-list->string rabbithole and wasn't thinking about just breaking down my list into strings using another method lol 1 Quote
Kreaten_vhar Posted October 10, 2022 Author Posted October 10, 2022 We've all been I'm sure lol 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.