OpenDCL Forums

OpenDCL => Runtime/AutoLISP => Topic started by: s.barszczewski on November 17, 2009, 02:13:41 AM

Title: equivalent of dcl_binfile_write/read/close
Post by: s.barszczewski on November 17, 2009, 02:13:41 AM
Hello everybody

I'm using autocad 2009 LT and autocad extender which allows to run lisp routines on autocad LT, opendcl is not 100% compatibile with this autocad extender so for example when normal autolisp syntax looks like this

(dcl_Form_Close abc_Form)

i have to divide it into such syntax (dcl_Form_Close "abc" "Form") to make it work on autocad 2009 LT and autocad extender, or i get prompt from opendcl : Bad argument

because I'm not able to force autocad 2009 LT to work with such code (normal autocad 2009 works with it ) :
Code (autolisp) Select
(setq file (dcl_BinFile_Open "c:\\file.txt" "r"))
(setq data (dcl_BinFile_Read file T)  <<< here I get opendcl prompt : bad argument
(dcl_BinFile_Close file)   <<< here I get opendcl prompt : bad argument



I'm looking for library or lisp routine which has similar functions to : dcl_binfile_open / dcl_binfile_write / dcl_binfile_read . Maybe one of you came across of such functions

Regards
Sebastian
s.barszczewski@wp.pl
Title: Re: equivalent of dcl_binfile_write/read/close
Post by: Fred Tomke on November 17, 2009, 03:56:53 AM
Hi, have you ever tried with the Scripting.FileSystemObject?

Fred
Title: Re: equivalent of dcl_binfile_write/read/close
Post by: DW on November 17, 2009, 11:49:01 PM
The other option might be to use OpenDCL 4.1.2.2 which does work with LT-Extender - but of course you need to rewrite your dialog project and will be limited to the older version.  Also binary file functions have different names in the older version.

David
Title: Re: equivalent of dcl_binfile_write/read/close
Post by: s.barszczewski on November 18, 2009, 03:34:26 AM
Quote from: Fred Tomke on November 17, 2009, 03:56:53 AM
Hi, have you ever tried with the Scripting.FileSystemObject?

Fred

what's that, can you give me short example ? I don't know what's that . Maybe you're talking about Microsoft Scripting Runtime Library?

regards
Sebastian
Title: Re: equivalent of dcl_binfile_write/read/close
Post by: Fred Tomke on November 18, 2009, 03:46:39 AM
Hi, I will give you an example later this day. I'm just in a customer training.

Fred
Title: Re: equivalent of dcl_binfile_write/read/close
Post by: Slavko Ivanovic on November 18, 2009, 09:48:21 AM
Hi barszczewski
Hi Fred

Fred, maybe no need for samples.

Barszczewski can check very nice samples by mr. Tony Tanzillo.:
lnk. to site http://www.caddzone.com/free.htm (http://www.caddzone.com/free.htm)
direct lnk. to sample http://www.caddzone.com/wsh.lsp (http://www.caddzone.com/wsh.lsp)


p.s. Fred
Are U Customer or Trainer ;)

Slavko
Title: Re: equivalent of dcl_binfile_write/read/close
Post by: Fred Tomke on November 18, 2009, 10:29:11 AM
Hi,

Quote from: Slavko Ivanovic on November 18, 2009, 09:48:21 AM
Fred, maybe no need for samples.

Hm, that's a really nice link, Slavko! Thank you! But I will publish a sample anyway. Maybe it is shorter. And finally, I'm not sure if AutoCAD LT makes it possible to get access to the ActiveX-object.

Code (autolisp) Select

(defun write_textfile (strFile uData isUnicode / filFile oFSObject oFSFile strZeile)
  (setq oFSObject (vlax-create-object "Scripting.FileSystemObject"))
  (setq oFSFile (vlax-invoke-method oFSObject "CreateTextFile" strFile :vlax-true (if isUnicode :vlax-true :vlax-false)))

  (if (listp uData)
    (foreach strZeile uData (vlax-invoke-method oFSFile 'WriteLine strZeile))
    (vlax-invoke-method oFSFile 'WriteLine uData)
  ); if
  (vlax-invoke-method oFSFile 'Close)
  (vlax-release-object oFSFile)
  (vlax-release-object oFSObject)
  T
); write_textfile


Quote from: Slavko Ivanovic on November 18, 2009, 09:48:21 AM
Are U Customer or Trainer ;)

I'm a AutoCAD Civil 3D trainer these days. ;)

Fred
Title: Re: equivalent of dcl_binfile_write/read/close
Post by: Slavko Ivanovic on November 19, 2009, 01:07:14 AM

And, barszczewski for other methods for
Code (autolisp) Select
(vlax-create-object "Scripting.FileSystemObject")
u can check
http://msdn.microsoft.com/en-us/library/z9ty6h50%28VS.85%29.aspx (http://msdn.microsoft.com/en-us/library/z9ty6h50%28VS.85%29.aspx)

Slavko