Page 1 of 1

OS error when trying to write to a file

Posted: Mon Dec 28, 2015 10:29 am
by Tim K
My app is giving this error at startup only on the first time it is run at each workstation. The second time it is started, it runs fine. It's writing to a file on a local drive.

Date : 12/28/15
Time : 09:10:56
Procedure : DC_PRINTER:INIT
Line Number : 596
Information : Error BASE/4
Description : Operating system error
Operation : set
Thread ID : 1
Source :
Called from : (B)INIT: _DCINIT(28)
Called from : DC_PRINTER:INIT(596)
Called from : DC_PRINTERON(3621)
Called from : STARTUP(370)
Called from : MCP(100)
Called from : MAIN(48)

This is the line of code:

BATFILE := "C:\POS\Z"+ALLTRIM(STR(G_STORENUM))+".BAT"
DCPRINT ON TEXTONLY OUTFILE (BATFILE) OVERWRITE

Suggestions?

Re: OS error when trying to write to a file

Posted: Mon Dec 28, 2015 11:03 am
by rdonnay
TEXTONLY mode uses the old Clipper style SET PRINTFILE TO <x>.
I don't know why this fails the first time.
Maybe a TEMP folder is needed.
Have you checked to see if a TEMP or TMP folder gets created?
Does the C:\POS folder already exist before running the first time?

Re: OS error when trying to write to a file

Posted: Wed Dec 30, 2015 2:42 pm
by Tim K
The C:\POS folder is most definitely there. Is there another method to do the same thing that I could use as a workaround?

Re: OS error when trying to write to a file

Posted: Thu Dec 31, 2015 12:54 am
by skiman
Hi,

Write it with low level functions. There is also a memowrit() function, but this may have problems with the eof character.

Code: Select all


BATFILE := "C:\POS\Z"+ALLTRIM(STR(G_STORENUM))+".BAT"
cText := "Whatever you need in your bat file."
abomemowrite(batfile,cText)


function abomemowrite(cTargetFile,cBuffer)
******************************************
Local nTarget := FCreate( cTargetFile, FC_NORMAL )

if nTarget == -1
    return .F.
  else
    FWrite( nTarget, cBuffer)
    FClose(ntarget)
endif 
    
return .T.

Re: OS error when trying to write to a file

Posted: Thu Dec 31, 2015 2:39 pm
by Tim K
Thanks, Chris!

Re: OS error when trying to write to a file

Posted: Mon Jan 04, 2016 8:01 am
by rdonnay
Write it with low level functions.
I was going to suggest that too, however I think that TEXT INTO is more appropriate for this project.

Code: Select all

BATFILE := "C:\POS\Z"+ALLTRIM(STR(G_STORENUM))+".BAT"

TEXT INTO cText WRAP
This is all of
the stuff that
I want in my batch
file.
ENDTEXT
abomemowrite(batfile,cText)