TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: domenicomaria on April 14, 2019, 05:06:38 AM

Title: PRINT a TXT file, from VISUAL LISP
Post by: domenicomaria on April 14, 2019, 05:06:38 AM
I need to
PRINT a TXT file, from VISUAL LISP . . .

But
(DOS_SPOOL "c:\\LISP\\BLA-BLA-BLA.txt" (DOS_GETPRN) )
does not work !

my printer
says :
"Receiving data"
but never prints anything . . .
Title: Re: PRINT a TXT file, from VISUAL LISP
Post by: roy_043 on April 14, 2019, 07:53:59 AM
Please stop posting the same problem again and again and again.
Title: Re: PRINT a TXT file, from VISUAL LISP
Post by: domenicomaria on April 14, 2019, 11:28:03 AM
Sorry !

I had a problem with your site !

When I try to send a post
it takes at least 10 minutes.

So I think that something is going wrong !

And later
i try again !

I apologize.

Please remove every thing
and leave only one instance !

sorry again !

ciao

Title: Re: PRINT a TXT file, from VISUAL LISP
Post by: BIGAL on April 14, 2019, 08:44:53 PM
Check this link

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-do-i-print-a-text-file-from-lisp/td-p/782982

Go to post 6 not tested.
Title: Re: PRINT a TXT file, from VISUAL LISP
Post by: domenicomaria on April 16, 2019, 03:42:09 AM
I tried :

(STARTAPP "print" path-filename-txt)

(DOS_SPOOL path-filename-txt (DOS_GETPRN) )

(STARTAPP "print /d:\"\\\\Dbroad\\Brother MFC-6490CW Printer\"" path-filename-txt)

. . .

they don't work
. . .
and however I don't understand
the syntax of the third row
. . .
I need a simple and working solution
. . .
ciao
Title: Re: PRINT a TXT file, from VISUAL LISP
Post by: roy_043 on April 16, 2019, 04:39:38 AM
Modern printers may not be able to handle a text file.
Try using notepad.exe. Look into its command line parameters.
Title: Re: PRINT a TXT file, from VISUAL LISP
Post by: kdub on April 16, 2019, 04:40:04 AM
I tried :

(STARTAPP "print" path-filename-txt)

(DOS_SPOOL path-filename-txt (DOS_GETPRN) )

(STARTAPP "print /d:\"\\\\Dbroad\\Brother MFC-6490CW Printer\"" path-filename-txt)

. . .

they don't work
. . .
and however I don't understand
the syntax of the third row
. . .
I need a simple and working solution
. . .
ciao

I imagine it's not working because that is/was the address of Doug Broads printer, not yours.
Title: Re: PRINT a TXT file, from VISUAL LISP
Post by: roy_043 on April 16, 2019, 07:01:26 AM
Try:
Code: [Select]
(startapp "notepad.exe /p \"X:\\Your path\\File.txt\"")
Title: Re: PRINT a TXT file, from VISUAL LISP
Post by: domenicomaria on April 16, 2019, 09:59:20 AM
"Sometimes the question is more important than the answer."
Yes. You are right !

"I imagine it's not working because that is/was
the address of Doug Broads printer, not yours."


What have I to do
to know my printer address
-> via Visual Lisp <- ?

or the printer address of a generic user ?
Title: Re: PRINT a TXT file, from VISUAL LISP
Post by: roy_043 on April 16, 2019, 01:03:12 PM
Some reading...
https://superuser.com/questions/477895/printing-from-windows-7-command-line
Title: Re: PRINT a TXT file, from VISUAL LISP
Post by: John Kaul (Se7en) on April 16, 2019, 02:50:39 PM
I did some work on this subject--in Cpp--at one point and it's a more difficult situation then one would expect. -i.e. if I remember properly, you can COPY a file to the COM/LPT port (COPY /B filename LPT1:) but the output depends file type you have (TXT, PS, PDF, etc.). In the end it is a big mess.

The knowing which COM/LPT port to send the information to is another big nasty problem. For my Cpp project I choose to use Redmon. Ultimately, I created redirected printer port(s) -i.e. connected a windows print driver to a redirected printer port and then used "redpr" (a better `copy to printer port method') to print my files. ...in the end, it is a bit of a mess and in the end, you'd probably be better off (save yourself a bunch of time) installing Redmon on everyone's machine (this can be automated).
Title: Re: PRINT a TXT file, from VISUAL LISP
Post by: Master_Shake on April 16, 2019, 03:28:17 PM
This thread has me intrigued, what would be the advantage or printing to a TXT file?
Title: Re: PRINT a TXT file, from VISUAL LISP
Post by: kdub on April 16, 2019, 03:54:06 PM
,INI file
.XML file
.CSV file
General data file
etc, etc


Title: Re: PRINT a TXT file, from VISUAL LISP
Post by: domenicomaria on April 16, 2019, 03:58:31 PM
"what would be the advantage or printing to a TXT file?"
I wrote my
(internal to Autocad)
NOTEPAD !

Everything works well.
But not PRINT !
Title: Re: PRINT a TXT file, from VISUAL LISP
Post by: dgorsman on April 16, 2019, 05:51:27 PM
This thread has me intrigued, what would be the advantage or printing to a TXT file?

You might be misreading this; it's about printing a TXT file to hard copy, not printing to a TXT file.

FYI, the MSXML DOM has a 'save' method to put the contents of an XML DOMDocument to file, so there's no need to use "print" like that.
Title: Re: PRINT a TXT file, from VISUAL LISP
Post by: VovKa on April 16, 2019, 06:57:47 PM
create MTEXT, get the bounding box, plot the window
Title: Re: PRINT a TXT file, from VISUAL LISP
Post by: domenicomaria on April 17, 2019, 02:57:00 AM
The true
is that
there is no real need
to print a TXT file !

Because everybody
can open a TXT, or INI or XML or LSP file
with a simple text editor
and print it.

I needed
to wrote
my Notepad
internal to Acad
. . .
and just
to make complete it
I want to be able
to print
the edited file.
. . .
Title: Re: PRINT a TXT file, from VISUAL LISP
Post by: roy_043 on April 17, 2019, 03:06:56 AM
My test shows that printing via notepad.exe works. And if you don't like the window that pops up, you can try calling notepad.exe via the Windows Scripting Host.
Title: Re: PRINT a TXT file, from VISUAL LISP
Post by: domenicomaria on April 17, 2019, 04:41:07 AM
yes
this
(startapp "notepad.exe /p \"X:\\Your path\\File.txt\"")
WORKS !
. . .
But I will be happy
if it will be possible
to get the access
to the printer preferences . . .
. . .
and
without cross
notepad . . . !

Title: Re: PRINT a TXT file, from VISUAL LISP
Post by: roy_043 on April 17, 2019, 05:46:50 AM
good
to
know
that
it
works
for
you
too
!
 :-D
Title: Re: PRINT a TXT file, from VISUAL LISP
Post by: domenicomaria on April 17, 2019, 06:16:30 AM
thank
you
very
much
!
!
!