Author Topic: AutoCAD 2008 and 2018's princ are different  (Read 1719 times)

0 Members and 1 Guest are viewing this topic.

baitang36

  • Bull Frog
  • Posts: 213
AutoCAD 2008 and 2018's princ are different
« on: August 11, 2021, 02:25:49 AM »
The execution results of the following code under AutoCAD2008 and 2018 are different, and the generated file contents are different
Code - Auto/Visual Lisp: [Select]
  1. (setq fo (open "d:/tt.txt" "w"))
  2.  (princ (strcat "aaa" (chr 256) "bbb") fo)
  3.  (close fo)
In other words, the function princ of the higher version of autoCAD has been castrated,  princ has lost the ability to write binary data

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8691
  • AKA Daniel
Re: AutoCAD 2008 and 2018's princ are different
« Reply #1 on: August 11, 2021, 03:04:37 AM »
is the 2008 version you're testing with 64bit?

VovKa

  • Water Moccasin
  • Posts: 1628
  • Ukraine
Re: AutoCAD 2008 and 2018's princ are different
« Reply #2 on: August 11, 2021, 05:39:51 AM »
In other words, the function princ of the higher version of autoCAD has been castrated,  princ has lost the ability to write binary data
i tested your code on acad2008 and the size of tt.txt is only 3 bytes
looks like my acad2008 is also 'castrated'

if you want to write 0 into the file then do it this way
Code: [Select]
(setq fo (open "d:/tt.txt" "w"))
    (foreach c '(97 97 97 256 98 98 98) (write-char c fo))
    (close fo)
or use 'ADODB.Stream'

baitang36

  • Bull Frog
  • Posts: 213
Re: AutoCAD 2008 and 2018's princ are different
« Reply #3 on: August 11, 2021, 07:55:27 PM »
In other words, the function princ of the higher version of autoCAD has been castrated,  princ has lost the ability to write binary data
i tested your code on acad2008 and the size of tt.txt is only 3 bytes
looks like my acad2008 is also 'castrated'

if you want to write 0 into the file then do it this way
Code: [Select]
(setq fo (open "d:/tt.txt" "w"))
    (foreach c '(97 97 97 256 98 98 98) (write-char c fo))
    (close fo)
or use 'ADODB.Stream'
thank you very much

baitang36

  • Bull Frog
  • Posts: 213
Re: AutoCAD 2008 and 2018's princ are different
« Reply #4 on: August 11, 2021, 08:01:01 PM »
In other words, the function princ of the higher version of autoCAD has been castrated,  princ has lost the ability to write binary data
i tested your code on acad2008 and the size of tt.txt is only 3 bytes
looks like my acad2008 is also 'castrated'

if you want to write 0 into the file then do it this way
Code: [Select]
(setq fo (open "d:/tt.txt" "w"))
    (foreach c '(97 97 97 256 98 98 98) (write-char c fo))
    (close fo)
or use 'ADODB.Stream'
After a test, this method can't write 10 to the file alone. It becomes 0D 0A .  one byte becomes two.
Code - Auto/Visual Lisp: [Select]
  1. (setq fo (open "d:/tt.txt" "w"))
  2.     (foreach c '(97 97 97 256 98 10 98) (write-char c fo))
  3.     (close fo)
  4.  
  5.  
« Last Edit: August 11, 2021, 08:05:20 PM by baitang36 »

mm_clover

  • Mosquito
  • Posts: 6
Re: AutoCAD 2008 and 2018's princ are different
« Reply #5 on: August 12, 2021, 11:26:26 AM »
0A=10,Hexadecimal?

VovKa

  • Water Moccasin
  • Posts: 1628
  • Ukraine
Re: AutoCAD 2008 and 2018's princ are different
« Reply #6 on: August 12, 2021, 03:38:28 PM »
In other words, the function princ of the higher version of autoCAD has been castrated,  princ has lost the ability to write binary data
i tested your code on acad2008 and the size of tt.txt is only 3 bytes
looks like my acad2008 is also 'castrated'

if you want to write 0 into the file then do it this way
Code: [Select]
(setq fo (open "d:/tt.txt" "w"))
    (foreach c '(97 97 97 256 98 98 98) (write-char c fo))
    (close fo)
or use 'ADODB.Stream'
After a test, this method can't write 10 to the file alone. It becomes 0D 0A .  one byte becomes two.
we can fool autocad the same way we did with 0
Code: [Select]
(setq fo (open "d:/tt.txt" "w"))
(foreach c '(97 97 97 256 98 266 98) (write-char c fo))
(close fo)

baitang36

  • Bull Frog
  • Posts: 213
Re: AutoCAD 2008 and 2018's princ are different
« Reply #7 on: August 13, 2021, 03:21:29 AM »
Code: [Select]
(setq fo (open "d:/tt.txt" "w"))
(foreach c '(97 97 97 256 98 266 98) (write-char c fo))
(close fo)
ok

d2010

  • Bull Frog
  • Posts: 326
Re: AutoCAD 2008 and 2018's princ are different
« Reply #8 on: August 13, 2021, 11:29:09 AM »
Can you found other solution?
Write char by char, into file-disk, you slow-down 100% entire Win10, because
many AntivirusPrograms, contain Real-LiveWatch of HardDisk

Code: [Select]
(setq fo (open "d:/tt.txt" "w"))
(foreach c '(97 97 97 256 98 266 98) (write-char c fo))
(close fo)
ok

baitang36

  • Bull Frog
  • Posts: 213
Re: AutoCAD 2008 and 2018's princ are different
« Reply #9 on: August 15, 2021, 09:35:57 AM »
Can you found other solution?
Write char by char, into file-disk, you slow-down 100% entire Win10, because
many AntivirusPrograms, contain Real-LiveWatch of HardDisk
You mean, write many bytes at a time?.This may use the unpublished function of Acad, which can read and write binary files. The compiler in vlide is also implemented with lisp