OpenFilePlus
Posted: Thu Jul 16, 2020 11:18 pm
I was getting errors opening my files, just because there were busy while opening them (I dont know why)
So I created OpenFilePlus, should be transparent to use.
It just try to open a file upto 10 times (with a 0.3s delay)
If times>1 then an INFO requester is shown
If times>10 it, a WARNING requester is shown and a failed to open is returned.
if acumulated errors>5 an ERROR requester is shown and the program is closed.
So I created OpenFilePlus, should be transparent to use.
It just try to open a file upto 10 times (with a 0.3s delay)
If times>1 then an INFO requester is shown
If times>10 it, a WARNING requester is shown and a failed to open is returned.
if acumulated errors>5 an ERROR requester is shown and the program is closed.
Code: Select all
Procedure.l OpenFilePlus(PB,path$,flags=0)
Define f.l,veces
Static errores
Repeat
f=OpenFile(pb,path$,flags)
If f=0
Delay(300):veces+1
EndIf
Until f<>0 Or veces=10
If veces>0 And veces<10
MessageRequester("Info at 'OpenFilePlus'","Have to try to open '"+path$+"', "+veces+" times",#PB_MessageRequester_Info)
errores+1
EndIf
If veces=>10
MessageRequester("Warning at 'OpenFilePlus'","I can't open '"+path$+"'",#PB_MessageRequester_Warning)
ProcedureReturn 0
EndIf
If errores>4
MessageRequester("Error at 'OpenFilePlus'","Too many errors accumulated. Program terminated",#PB_MessageRequester_Error)
End
Else
ProcedureReturn f
EndIf
EndProcedure