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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HOW TO CHECK IF A FILE EXISTS AND IS ALREADY FINISHED

Status
Not open for further replies.

RubensLott

Programmer
Oct 2, 2017
10
0
0
BR
Godd Morning!!![bigsmile]

I have a simple situation but my solution is not working good.[bugeyed]
The situation is that I'm recording a PDF file and I ave to check if it exists (FileExists works OK) AND if it's generation is already finished.... I tried to use FileOpen/FileRead/FileClose but it´s not OK.... This is within a looping cause I have do record more than one file and I can work only one file at a time...

These are my code lines:

...
li_sair = -1
ls_dados = '/' // The first line is a system dateusing 'dd/mm/yyyy'
li_nroarq = FileOpen(ls_arqorigem)
DO WHILE li_sair = -1
li_sair = FileRead(li_nroarq, ls_dados) - // it's returning -1 (error)
LOOP
FileClose(li_nroarq)
...

Any tips?[ponder]
Thanks in advance...[wink]
 
From the PowerBuilder help file on 'FileOpen PowerScript Function':

File not found
If PowerBuilder does not find the file, it creates a new file, giving it the specified name,
if the fileaccess argument is set to Write!. If the argument is not set to Write!, FileOpen returns -1.


The default fileaccess is Read! so you may need to change your call to something like:

[pre]Fileopen('c:\temp\myfile.txt', StreamMode!, Write!)[/pre]

- Matt


"Nature forges everything on the anvil of time"
 
Thank You MBALENT for the tip.... But it closed the application.... Did not workout..... So I tried READ! instead and it worked!
Thanks again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top