Author |
Topic  |
|
ILLHILL
Junior Member
 
Netherlands
341 Posts |
Posted - 06 June 2007 : 19:38:58
|
Hi guys, I try to prevent an 800a003e error. Google helped me find out that this is due to a textfile with a size of 0kb. So I know I have to find out if the file is > 0Kb before it gets loaded. The code should look something like the following, but it doesn't work, so I expect there to be a bug in there :( Anybody can spot the error?
Function getCachedFile(strFileName03)
Dim cacheFSO : Set cacheFSO = CreateObject("Scripting.FileSystemObject")
Dim Fil : Set Fil = cacheFSO.getFile("xxxx link to file xxxx\" & strFileName03,1,False,0)
if Fil.size > 0 then
Dim cacheFile : Set cacheFile = cacheFSO.OpenTextFile("xxxx link to file xxxx\" & strFileName03,1,False,0)
getCachedFile = cacheFile.ReadAll
else
Set cacheFile = "File was empty"
end if
Set Fil = nothing
Set cacheFile = Nothing
Set cacheFSO = Nothing
End Function
Greets & thanks,
Dominic |
CLPPR.com - All The News Only Seconds Away |
|
pdrg
Support Moderator
    
United Kingdom
2897 Posts |
Posted - 07 June 2007 : 15:47:08
|
'SET' is used for an object (not a variable) reference, so Set cacheFile = "File was empty" would probably bork as MarshalMix suggests |
 |
|
ILLHILL
Junior Member
 
Netherlands
341 Posts |
Posted - 07 June 2007 : 18:30:23
|
Thanks guys, I shouldn't try to work on code while it's time to go to bed :)
Eventually it's working and this is how the code looks now:
Function getCachedFile(strFileName03)
Dim cacheFSO : Set cacheFSO = CreateObject("Scripting.FileSystemObject")
Dim fil : Set fil = cacheFSO.getFile("x://somewhere on the server" & strFileName03)
if fil.size > 0 then
Dim cacheFile : Set cacheFile = cacheFSO.OpenTextFile("x://somewhere on the server" & strFileName03,1,0,0)
getCachedFile = cacheFile.ReadAll
Set cacheFile = Nothing
else
getCachedFile = "File Is Empty"
end if
Set fil = Nothing
Set cacheFSO = Nothing
End Function
In the end, I found out I had to remove the settings in the GetFile line (,1,0,0). Of course after I changed the thing you suggested.
Thanks & greets,
Dominic
|
CLPPR.com - All The News Only Seconds Away |
Edited by - ILLHILL on 07 June 2007 18:32:43 |
 |
|
pdrg
Support Moderator
    
United Kingdom
2897 Posts |
Posted - 08 June 2007 : 12:54:09
|
quote: Originally posted by ILLHILL
Thanks guys, I shouldn't try to work on code while it's time to go to bed :)
Nonsense, it's the only time [;-)]
Glad you got it all going :) |
 |
|
ILLHILL
Junior Member
 
Netherlands
341 Posts |
Posted - 12 July 2007 : 16:58:00
|
One final thing. I got this part to work, thanks to MarshalMix & prdg, but what I was wondering is if it is possible to determine whether the source is 0byte.
I noticed this happens with the del.icio.us feed every now and then. Sometimes when the feed is loaded and cached, it turns out to save as a 0byte cache txt file. Due to the above method, I can react to it when the cache is then read and turns out to be 0byte. However, I have a bit less control over the actual session that writes the cache. (Meaning the first visitor who decides to load the del.icio.us feed, when the cache version has expired. This person will still receive an error).
I have sort of debugged this with the use of "on error resume" but would like to do this in a bit more "pretty" way.
Any ideas as of how to do this and if it's possible? The code-part of the parse script filters out certain errors if an rss can not be parsed, but the rss = 0Kb situation is one it can't intercept.
Not really a big deal, as said if the cache is already written as a 0byte txt file then the error is filtered out from that point on. It is just the moment a visitor session results in the cache being written when it is a bit bugging. If he/she thinks "what the heck" and submits the faulty feed once more he/she will see the "Sorry try again later" message appear, which explains that the rss is currently unavailable.
Hope this makes sense, and quite hard to simulate as the del.icio.us feed doesn't seem to have this problem as often as it had before.
Greets, Dominic
|
CLPPR.com - All The News Only Seconds Away |
 |
|
|
Topic  |
|
|
|