Page 1 of 1
[Implemented] 2 simple & useful functions needed
Posted: Thu Mar 27, 2003 9:38 pm
by BackupUser
Restored from previous forum. Originally posted by lanael.
FileExists( Filename$ )
Test if a file exists
return 1 if found, 0 otherwise.
Milliseconds()
Return the number of milliseconds since the computer starts
( I think every OS has it )
/* don't believe, just think */
Posted: Thu Mar 27, 2003 10:13 pm
by BackupUser
Restored from previous forum. Originally posted by Justin.
This is my version of fileexist, there are other alternatives.
Code: Select all
#HFILE_ERROR=-1
sof.OFSTRUCT
global sof
;test if a file exists
;Returns: true if exists, false otherwise
procedure fileexist(file$)
if OpenFile_(file$,@sof,#OF_EXIST)=#HFILE_ERROR
procedurereturn 0
else
procedurereturn 1
endif
endprocedure
Posted: Thu Mar 27, 2003 10:27 pm
by BackupUser
Restored from previous forum. Originally posted by lanael.
Oh, ok.
I've not looked enough on these '_'-suffixed functions (kind of low-level ?? )
But a filexist function included in the language would be fine !
Thanks anyway.
/* don't believe, just think */
Posted: Thu Mar 27, 2003 10:42 pm
by BackupUser
Restored from previous forum. Originally posted by PB.
> FileExists( Filename$ )
If FileSize(filename$)=-1 : Debug "File does NOT exist!" : EndIf
> Milliseconds()
For Windows only: GetTickCount_()
Posted: Thu Mar 27, 2003 10:43 pm
by BackupUser
Restored from previous forum. Originally posted by Pupil.
You can also use the command FileSize() to check if a file exist or not. The command returns -1 if file doesn't exist and -2 if the filename you've provided is a directory name..
example:
Code: Select all
If FileSize(filename$) = -1
; File doesn't exist
EndIf
If you want the milliseconds elapsed since computer was turned on you can use this:
Code: Select all
msecs.l = GetTickCount_() ; Win OS only
Posted: Fri Mar 28, 2003 12:33 am
by BackupUser
Restored from previous forum. Originally posted by ricardo.
'_'-suffixed functions (kind of low-level ?? )
Windows API
http://www.allapi.net
Best Regards
Ricardo
Dont cry for me Argentina...