Restored from previous forum. Originally posted by Ralf.
I wrote a programm which should the whether a file is there or not.
If C:\DB95-EIN\.....002 is not there is should go further to check
whether .001 is there but my programm stops after it checked and found
out that there is no .002. But i have .001 and it should tell me.
Whats wrong with it ?
b$="."
GetLocalTime_(time.SYSTEMTIME)
b$=b$+Str(time\wYear)
a$=Str(time\wMonth): If Len(a$)=1 : a$="0"+a$ : EndIf : b$=b$+a$
a$=Str(time\wDay-1) : If Len(a$)=1 : a$="0"+a$ : EndIf : b$=b$+a$
ReadFile$ = "C:\DB95-EIN\B100016" + b$ + ".001"
ReadFile2$ = "C:\DB95-EIN\B100016" + b$ + ".002"
If ReadFile(1, ReadFile2$)
MessageRequester("Dateieingang: ","DATEI: " + ReadFile2$ + " vorhanden ...", 0)
CloseFile(1)
Else
MessageRequester("Nachricht", "Fehler: Kann Datei" + ReadFile2$ + " nicht lesen !", 0)
ElseIf ReadFile(2, ReadFile$)
MessageRequester("Dateieingang: ","DATEI: " + ReadFile$ + " vorhanden ...", 0)
CloseFile(2)
Else
MessageRequester("Nachricht", "Fehler: Kann Datei nicht lesen !", 0)
EndIf
Question to ELSE ELSEIF ENDIF
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Saboteur.
Else optional command is used to execute a part of code, if all previous tests were false.
Only can put 1 else, the syntax is:
IF ...
ELSEIF ...
ELSE ...
ENDIF
Win98 Athlon 1200 256DDR ATI RADEON 9000
In manual:Originally posted by Ralf
I wrote a programm which should the whether a file is there or not.
If C:\DB95-EIN\.....002 is not there is should go further to check
whether .001 is there but my programm stops after it checked and found
out that there is no .002. But i have .001 and it should tell me.
Whats wrong with it ?
b$="."
GetLocalTime_(time.SYSTEMTIME)
b$=b$+Str(time\wYear)
a$=Str(time\wMonth): If Len(a$)=1 : a$="0"+a$ : EndIf : b$=b$+a$
a$=Str(time\wDay-1) : If Len(a$)=1 : a$="0"+a$ : EndIf : b$=b$+a$
ReadFile$ = "C:\DB95-EIN\B100016" + b$ + ".001"
ReadFile2$ = "C:\DB95-EIN\B100016" + b$ + ".002"
If ReadFile(1, ReadFile2$)
MessageRequester("Dateieingang: ","DATEI: " + ReadFile2$ + " vorhanden ...", 0)
CloseFile(1)
;..............................
;Else <- no, no, this else don't work here
; MessageRequester("Nachricht", "Fehler: Kann Datei" + ReadFile2$ + " nicht lesen !", 0)
;..............................
ElseIf ReadFile(2, ReadFile$)
MessageRequester("Dateieingang: ","DATEI: " + ReadFile$ + " vorhanden ...", 0)
CloseFile(2)
Else
MessageRequester("Nachricht", "Fehler: Kann Datei nicht lesen !", 0)
EndIf
Else optional command is used to execute a part of code, if all previous tests were false.
Only can put 1 else, the syntax is:
IF ...
ELSEIF ...
ELSE ...
ENDIF
Win98 Athlon 1200 256DDR ATI RADEON 9000