Author Topic: read-line issue ? or variable setting ?  (Read 1830 times)

0 Members and 1 Guest are viewing this topic.

Andrea

  • Water Moccasin
  • Posts: 2372
read-line issue ? or variable setting ?
« on: December 09, 2014, 12:25:57 PM »
Hi all,..

anyone can run READ-LINE on this file ???

Code: [Select]
(setq file (open "C:\\test\\test2.txt" "r"))
(setq rline (read-line file))
(close file)

it return..
Code: [Select]
"˙ŝt\000e\000s\000t\000f\000i\000l\000e\000"
??
Keep smile...

ronjonp

  • Needs a day job
  • Posts: 7527
Re: read-line issue ? or variable setting ?
« Reply #1 on: December 09, 2014, 12:30:23 PM »
Same here. This is probably the culprit.

« Last Edit: December 09, 2014, 12:34:17 PM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Andrea

  • Water Moccasin
  • Posts: 2372
Re: read-line issue ? or variable setting ?
« Reply #2 on: December 09, 2014, 12:33:33 PM »
I check the file propreties...all seem ok..
strange thing... :|
Keep smile...

Andrea

  • Water Moccasin
  • Posts: 2372
Re: read-line issue ? or variable setting ?
« Reply #3 on: December 09, 2014, 12:50:46 PM »
Same here. This is probably the culprit.

Bingo !  thank you very much Ron !
Now I've to figureout how to change this proprety...

thanks again. :)
Keep smile...

Andrea

  • Water Moccasin
  • Posts: 2372
Re: read-line issue ? or variable setting ?
« Reply #4 on: December 09, 2014, 01:25:11 PM »
there...

Code: [Select]
(defun ReadasUnicode (file / fsobj readalldoc)
  (if (findfile file)
    (progn
      (setq fsobj (vlax-create-object "Scripting.FileSystemObject"))
      (setq file (vlax-invoke-method fsobj 'OpenTextFile file 1 :vlax-false -2))
      (setq readalldoc (vlax-invoke file 'readall))
      (vlax-invoke file 'close)
      (vlax-release-object fsobj)
      (vlax-release-object file)
      (princ)
    )
  )
  readalldoc
)

any other suggestion ?
« Last Edit: December 09, 2014, 01:49:29 PM by Andrea »
Keep smile...

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: read-line issue ? or variable setting ?
« Reply #5 on: December 10, 2014, 05:37:51 AM »
Since you are also working with BricsCAD this may be of interest:
Code: [Select]
(defun BinReadUnInt16 (fileName / fptr int ret)
  (setq fptr (open fileName "rb"))
  (while (setq int (vle-read-uint16  fptr))
    (setq ret (cons int ret))
  )
  (close fptr)
  (reverse ret)
)

Code: [Select]
(BinReadUnInt16 "C:/downloads/test2.txt") => (65279 116 101 115 116 102 105 108 101 13 10)
Code: [Select]
(vl-list->string (BinReadUnInt16 "C:/downloads/test2.txt")) => "˙testfile\r\n"
BTW:
According to the BricsCAD 'Lisp Developer Support Package' AutoLisp also supports (open <filename> "rb") and (open <filename> "wb"). Where "rb" stands for "read binary" and "wb" for "write binary".

VovKa

  • Water Moccasin
  • Posts: 1629
  • Ukraine
Re: read-line issue ? or variable setting ?
« Reply #6 on: December 10, 2014, 07:02:00 AM »
http://www.theswamp.org/index.php?topic=39617.msg449060#msg449060
Code: [Select]
(vk_ReadTextStream "C:\\test\\test2.txt" "utf-16")

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: read-line issue ? or variable setting ?
« Reply #7 on: December 10, 2014, 08:51:16 AM »
This might also be of some interest:
http://www.theswamp.org/index.php?topic=39814.0