Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Questions & Help Needed
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Questions & Help Needed Post any question regarding Basic4ppc.


FileSize(file) brings up error on device - but not on Desktop


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-09-2008, 11:07 PM
Knows the basics
 
Join Date: Apr 2008
Location: Duesseldorf, Germany
Posts: 71
Default FileSize(file) brings up error on device - but not on Desktop

Hello,

when i tested my app on the device today, i got an unspecified error message within a sub upon program start.I don't get this error on the desktop emu, so i didn't realize this for a longer time and believed everything is fine.

I installed then the System_SR_ENU.CAB on my device to get a clue what the problem is.

I get now this error:

"Could not find the file \Temp\afilename"

This error occurs while executing:

Code:
Sub Globals
...
LogFileName = "\Temp\myfile"
...
End Sub


If FileExist(LogFileName)  = true AND FileSize (LogfileName) > 0  =  true Then 
FileOpen (FileHandle,LogFileName,cRead)
...
Else
MsgBox(LogFileName & " does not exist..!")
End if
...
End Sub
If i use

Code:
 FileOpen(LogFileHandle,LogFileName, cWrite ,cAppend,)
later in the code, it properly creates the file without error message using the same path/file, the FileExist doesn't seem to like.

As i already mentinoned, on the desktop no error message at all occurs, even if the file/path does not exist.That is what the check for is..:-)

By testing i found, that the ...FileSize (LogfileName) > 0 statement seems to be the problem.

I assume now:

- FileExist(file) works ok on Desktop and Device
- FileSize(file) is generating an error, if (file) does not exist, on device, but not on desktop.

Can anyone confirm that..? Is this a (know or unknown) bug..?


cheers

TWELVE
Reply With Quote
  #2 (permalink)  
Old 05-09-2008, 11:55 PM
Cableguy's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: N 41º11'30.30" W 8º39'46.60"
Posts: 1,343
Awards Showcase
Forum Contributer 
Total Awards: 1
Default

y tadd the ApPahkeywo in he file path...

something like...

LogFileName = AppPath & "\Temp\myfile"

You may be looking for the file in the wrong folder....
__________________
Paulo Gomes
Porto, Portugal

PC: Dual-Core 1,8Ghz, 2GB RAM, 80GB HD
PPC: Qtek9000, 1GB SD

DLL Version Listing
Reply With Quote
  #3 (permalink)  
Old 05-10-2008, 02:35 AM
Knows the basics
 
Join Date: Apr 2008
Location: Duesseldorf, Germany
Posts: 71
Default

Quote:
y tadd the ApPahkeywo in he file path...
What's this..? :-)

Quote:
You may be looking for the file in the wrong folder....
If i was looking to the wrong file/path, how can i create the file then with FileOpen and the same path/file..? No please that's way to easy to be a solution for this
difficulty thingy..:-)

Last edited by TWELVE : 05-10-2008 at 02:38 AM.
Reply With Quote
  #4 (permalink)  
Old 05-10-2008, 06:32 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,199
Default

Quote:
I assume now:

- FileExist(file) works ok on Desktop and Device
- FileSize(file) is generating an error, if (file) does not exist, on device, but not on desktop.
If the file doesn't exist the program will not reach the FileSize method.
Try to run your code from the device IDE and see which line raises the error.
Reply With Quote
  #5 (permalink)  
Old 05-10-2008, 02:38 PM
Knows the basics
 
Join Date: Apr 2008
Location: Duesseldorf, Germany
Posts: 71
Default

The error occurs if the file does not exist, but only on device, as outlined above.

I do it now this way:

Code:
If FileExist(LogFileName)  = true  Then 
  If FileSize (LogfileName) > 0  =  true Then
Makes more sense, because i cannot ask the size of a file that doesn't exist.I didn't realize this because the error does not occur when run from desktop IDE.Probably on desktop the FileSize gives just zero as size back if the file does not exist, on the device is raises the error message.

I found also some other differences between desktop and device ( sizing of gui elements/controls, font to large for a button, Tabcontrol not visible if the assigned form is too large in size...), which makes development a bit difficult.
I cannot trust on the desktop and need to test the app on the device before i give that out to someone else.


regards

TWELVE
Reply With Quote
  #6 (permalink)  
Old 05-10-2008, 02:45 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,199
Default

There is a syntax error in your code:
Code:
If FileExist(LogFileName)  = true AND FileSize (LogfileName) > 0  =  true Then
It should be:
Code:
If FileExist(LogFileName)  = true AND FileSize (LogfileName) > 0 Then
Reply With Quote
  #7 (permalink)  
Old 05-10-2008, 03:07 PM
Knows the basics
 
Join Date: Apr 2008
Location: Duesseldorf, Germany
Posts: 71
Default

Quote:
There is a syntax error in your code:
You're right :-) Although i don't think that has caused the error message..do you..?

cheers

TWELVE
Reply With Quote
  #8 (permalink)  
Old 05-10-2008, 03:54 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,199
Default

Quote:
Although i don't think that has caused the error message..do you..?
Basic4ppc uses "short circuit" conditions (like C operators: && and ||)
Which means that if the file doesn't exist, its size will not be checked.
Due to the syntax error the conditions were not checked correctly.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Web browser for desktop and device agraham Additional Libraries 49 11-23-2008 06:12 PM
Device or Desktop DaveW Questions & Help Needed 2 11-07-2008 01:04 PM
Device Error: file/assembly not found Dave Mitchell Questions & Help Needed 6 05-09-2008 12:30 AM
Different behaviour DeskTop and Device HARRY Questions & Help Needed 2 02-22-2008 01:36 PM
Using rapi from desktop to copy file from device to desktop sunnyboyj Questions & Help Needed 9 02-08-2008 12:40 PM


All times are GMT. The time now is 02:32 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0