Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FoxPro 2.6 for DOS and Serial port printing on W2K

Status
Not open for further replies.

JairRunfesco

Programmer
Sep 28, 2005
3
AR
Hi!

I've read thread182-773737 and many others, that say "search the database", but offers no solution.
Please, don't do that. I've looked about 300 threads before posting this, and the search engine sucks.

Scenario:
OS Windows 2000 Pro SP4
FoxPro 2.6 for DOS app
trying to print to serial printer (com1), and fails

it fails:
1) trying to FOPEN(port)
2) trying to write to a text file and then send it to the port ( ! type commands > com1 ) or (! foxswap /120 type commands > com1)

Any substantial idea?

 
Since you mention using FOPEN(), I need to ask...
* Are you really printing?
* Or are you attempting to send/receive data through a serial port?

If you are just printing, do you have specific
Code:
SET PRINTER TO COM1 && Or whatever COM Port
commands within your application?

If so get rid of them.
Let Windows do the work of getting the printout to the workstation default printer via the correct port.

If you need to change the workstation default printer, then you will need to add some extra code.

Good Luck,

JRB-Bldr
VisionQuest Consulting
Business Analyst & CIO Consulting Services
CIOServices@yahoo.com
 
just printing...

meanwhile, this works:

set printer to
SET PRINTER TO COM1, 38400, E, 7, 1, H, RL

! mode com1 baud=38400 parity=e data=7 stop=1
! mode lpt3 = com1

**** in this part the app creates a file named "data1" with the commands to the printer


set printer to lpt3
type data1 to printer


but its veeeeeery sloooow
 
In your code above you appear to still be using SET PRINTER TO <something>.

My advice is to get rid of all of those lines and let Windows handle the "where/how" to print.

Some additional reading you might want to look over...
Here is an easy Print Spooler
thread182-155776

Problems with my printer
thread182-331170

How to make Printer Outputs start quicker?
FAQ182-785

In a previous rgbean posting...
Launch a registry editor (either REGEDIT OR REGEDT32)

In \HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\WOW,
there should be a key named "LPT_timeout", set to a default value of 15 seconds. Change the value of LPT_timeout from 15 to 1.

Your DOS print jobs should start faster."

XP PC runs slow with Foxpro 2.6 app minimized
thread182-537721

Also...
Check the SPOOL settings in the Windows Control Panel Print Driver for your printer on the Advanced tab page. Set this to Start Printing Immediately.

Finally....
I know you haven't been very successful with your attempts to use this forum's Search utility, you just have to get "creative" with your search phrases and try various combinations. Regardless, if you do a Search with "printing slow" you will get a number of answers as well.

Good Luck,


JRB-Bldr
VisionQuest Consulting
Business Analyst & CIO Consulting Services
CIOServices@yahoo.com
 
I did not have any success in this screnario (FOPEN('COM')). I think dos foxpro uses bios service (int 14h) and bios NEEDS hardware handshake. It means, you must facilitate CTR and DSR dignal on COM in logic one.
Do you have correct serial cable. There are many variants of serial cables.
Due this (and many other) I do direct access to com (without bios). It can not be done directly in foxpro language, but you can use some PLB library which have function like IN and OUT to/from ports.
In DOS windows in Win 95-XP it is possible.


Tomas
 
In your startup batch file add the lines....
mode com1 96,n,8,1
mode lpt2 = com1

Now set your FPD app to print to LPT2

That simple.
( you may need to change the first "mode" line to suit your printer)

Aussie Ken
"Far, Far Away"
CAMIGUIN
 
but its veeeeeery sloooow
Serial printer by nature is veeeeeery sloooow. If you're printing anything sizey at all, it will take a lot longer than paralell or USB.

Here is a routine I use to print a receipt on a serial printer. See if it helps you any:
Code:
PARAMETERS lIsTest

IF PARAMETERS() = 1
   lIsTest = .T.
   nNextNum = 999999
ELSE
   lIsTest = .F.
ENDIF

*... This configuration is compiled from running the
*...    "=CallFn(getcomm, 0, @cOldState)" function below.
STORE ;
   CHR(0) + ;
   CHR(128) + ;
   CHR(37) + ;
   CHR(7) + ;
   CHR(2) + ;
   CHR(0) + ;
   CHR(0) + ;
   CHR(0) + ;
   CHR(0) + ;
   CHR(0) + ;
   CHR(0) + ;
   CHR(0) + ;
   CHR(1) + ;
   CHR(0) + ;
   CHR(17) + ;
   CHR(19) + ;
   CHR(10) + ;
   CHR(0) + ;
   CHR(10) + ;
   CHR(0) + ;
   CHR(0) + ;
   CHR(0) + ;
   CHR(0) + ;
   CHR(0) + ;
   CHR(0) ;
   TO coldstate, cnewstate


opencomm  = RegFn("OpenComm", "CII", "I")
writecomm = RegFn("WriteComm", "ICI", "I")
closecomm = RegFn("CloseComm", "I", "I")
getcomm   = RegFn("GetCommState", "I@C", "I")
setcomm   = RegFn("SetCommState", "I@C", "I")

*... open the comm port here
STORE 'COM' + ALLTRIM(STR(rcptport)) + ":" TO crcptport
out_com = callfn(opencomm, crcptport, 100, 100)
IF out_com = -1
   DO caution WITH "*** CONFIGURATION ERROR ***", ;
      "Unable to open communications port to print receipt!"
   RETURN
ENDIF

*... get comm parameters just for comparison
=callfn(getcomm, 0, @cOldState)

*... set required comm parameters - 9600,7,E,1 according to above
=callfn(setcomm, 0, @cNewState)

WAIT WINDOW "Printing receipt # " + ALLTRIM(STR(nNextNum)) + "......" NOWAIT
*... header
=serialout(PADC(ALLTRIM(companyname), 40, ' '))
=serialout(PADC(ALLTRIM(m.cust_name), 40, ' '))

*... blank lines
FOR nline = 1 TO 5
   =serialout('')
NEXT

*...  If we're just calling this routine from the config screen
IF lIsTest
   STORE 0 TO m.dollar_value   &&... just so there's no error
   *... print test stuff
   =serialout('Date_________: ' + DTOC(DATE()))
   =serialout('Time_________: ' + TIME())
   =serialout('Cashier______: ' + m.s_username)
   =serialout('Member Name__: Test Member')
   =serialout('Member Number: 12345678')
   =serialout('Description__: Test Print RDM')
   =serialout('Points Ded.__: (0000.00)')
   =serialout('Dollar Value_: $0000.00')
   =serialout('Receipt #:___: 999999')
ELSE
   *... print real stuff
   =serialout('Date_________: ' + cPCDate)
   =serialout('Time_________: ' + cPCTime)
   =serialout('Cashier______: ' + m.s_username)
   =serialout('Member Name__: ' + ALLTRIM(m.ar_rpt_name ))
   =serialout('Member Number: ' + ALLTRIM(m.a_cif_nbr))
   =serialout('Description__: ' + ALLTRIM(m.ar_desc)), 40)
   =serialout('Points Ded.__: (' + ALLTRIM(STR(m.pnt_value))+ ')')
   =serialout('Dollar Value_: $' + ALLTRIM(STR(m.dollar_value)) + '.00')
   =serialout('Receipt #:___: ' + ALLTRIM(STR(nNextNum)))
ENDIF

*... blank lines
FOR nline = 1 TO 5
   =serialout('')
NEXT

*... Customer signature line
=serialout('X' + REPLICATE('_', 38))
=serialout('  Customer Signature')
=serialout('')
=serialout('')

*... Club signature line
=serialout('X' + REPLICATE('_', 38))
=serialout('  Club Signature')
=serialout('')
=serialout('')

*... Cashier signature line
=serialout('X' + REPLICATE('_', 38))
=serialout('  Cashier Signature')
=serialout('')
=serialout('')

IF lIsTest .OR. m.dollar_value > 0   &&... they may change their mind for mgr sig amount
   *... Manager signature line
   =serialout('X' + REPLICATE('_', 38))
   =serialout('  Manager Signature')
   =serialout('')
   =serialout('')
ENDIF

FOR nline = 1 TO 10  &&... blank lines
   =serialout('')
NEXT

*... cut paper
=serialout(CHR(27) + 'i')

*... blank lines
FOR nline = 1 TO 3
   =serialout('')
NEXT

*... close port for now
=callfn(closecomm, out_com)

WAIT CLEAR
RETURN



*...................... output workhorse ............................*
FUNCTION serialout
PARAMETERS coutstr

coutstr = LEFT(coutstr, 40) + CHR(13) + CHR(10)
=callfn(writecomm, out_com, coutstr, LEN(coutstr))
=INKEY(.1, 'HM')
RETURN

*:EOF ...rdmrcpt

-Dave Summers-
[cheers]
Even more Fox stuff at:
 
To Dave Summers: original ask was "Foxpro in DOS", RegFn() is not command in foxpro dos :)


Serial printer reconfigured to LPTx is very slow because foxpro (dos) does not close print job. Foxpro closes only job printed to LPT1. One "glue" is change LPT_timeout in registry, but close print job (for immediate printing) on ANY lpt port is possible - you can see
Tomas
 
I have to disagree Ezopaci, serial is no slower than parallel.
The only problem is data loss.
If you print too much too fast, some data just disapears.
I have dozens of serial printers hooked up via the two "mode" commands and experience no problem except for the data loss.
To get around it I slow data output to serial printers with a little "time waster".

??? "THIS"
??? "THAT"
do waster
??? "THE OTHER

*----------------------
procedure waster
*
if printer = "LPT2"
wait window "" timout .2
endif
return
 
To: Tilltek
I did not say about phisicaly speed of interface. Slower is printing from dos program to parallel port 2 and 3 due a problem "port/job closing" as I wrote before.

About problem "data loss" - on serial line you have to set correct handshaking on both side (best is hardware handshake), one is PC (soft) and other is printer (dip switches on it). Then you could not get any problem with lost of data. WAIT WINDOW is not "clear" solution :)

Tomas
 
To: Tilltek again
I remember one case with Epson bon printer. There is (on some models) problem with slow handshaking and due this here is possible of some data loss.

Tomas
 
ezopaci? Tillitek?

If the person is printing from a Windows ME or higher Workstation the SERIAL PORT IS LOCKED BY MS OS unless it is a networked serial printer and you have the driver and "ADDRESS OF PRINTER" to print to, installed on your PC.

I got this streight from the MS Tek Guys.

The only way to print is to Parallel and I have made routines where I disguised the PARALLEL TO BE LIKE A COM PORT and it is SLOWER THAN MOLASSES.

Now on the other hand if you have a DOS workstation then you are ok. Just don't have a Windows Server with a Foxpro DOS version because it will use up your CPU by the time you connect more than three users the system will start crashing even if you use TameDos or DPAKBD.

The reason is that Foxpro DOS manages its own CPU and Memory use and that conflicts with the way Windows Handles it.

OK got to go.

Later guys.
 
(sorry my English)
about "serial port locked":
NTVDM subsystem exist on NT and up win.systems (NT virtual dos machine). There is possible use serial port (and parallel) very easy by dos or bios function. NTVDM virtualize serial port by software and translate any dos command for access on serial port to win32 api function. You can use EVEN INTERRUPTS on s.port.
When you first access on port, then windows LOCK port for dos and then is not accessible from any other application, until you close dos session.

about "system crashing":
No, I have many of users who uses Win 2K or XP like a file server with running one or more dos windows with Fox and I don't have any marginal problem.

about memory:
dos FoxPro 2.6 is dpmi client and ntvdm is dpmi server, you can simply set amount of memory foxpro will use by MEMLIMIT in CONFIG.FP

About TAMEDOS and cpu utilize: on inet you can find program foxfree.


Tomas
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top