Scripting.FileSystemObject error! 
Author Message
 Scripting.FileSystemObject error!

I posted earlier thinking my changes to the database were the cause of my
error.  Now I have narrowed the problem down to one line of code.  I have
problems with the following function:
______________________
Function getVariable(var)
  Dim f, fso, str
  on error resume next
  getVariable = Null
  'Set fso = Wscript.CreateObject("Scripting.FileSystemObject") //PROBLEM
LINE!!!

  Set f = fso.OpenTextFile(VARS) // also tried: Set f =
fso.OpenTextFile(VARS, 1)
  if err then
    error = error&"Can't open variables file "&VARS&vbNewLine
    error = error&err.description&vbNewLine
    reportError()
    WScript.Quit
  end if
  Do While f.AtEndOfStream <> True    
    str = f.Read(len(var))
    if StrComp(str, var, 1) = 0 then
      getVariable = Trim(f.readline)
      f.close
      exit function
    end if
    if f.AtEndOfStream = True then
      exit function
    end if
    f.SkipLine  
  Loop
  f.close
End Function 'getVariable
_________________
This function simply reads a variable declaration from a file named by VARS
which is set up like:
VARIABLE_NAME variable value
VARIABLE_NAME2 variable2 value
and so on
If  I comment out the line indicated above, it works as expected (I get an
Object Required error).  If I leave that line in, I get:
___error message___
The instruction at "0x6539a89a" referenced memory at "0x00000008".  The
memory could not be "read".
Click on OK to terminate the application
___end of error message___

This is very important so any help you can give is greatly appreciated.

A twist:  I have WORKING ASP pages that read files, and here is a snippet
of code (on the same computer) that works 100%
  set fs = CreateObject("Scripting.FileSystemObject")
  set a = fs.OpenTextFile(LOGFILE,1,0)
  file = a.ReadAll
  a.Close()  
  set a = Nothing
  Response.Write file

I am not very wise in the ways of scripting, but I believe the ASP page has
a completely different engine, no?

Thanks to anyone who can help!



Sat, 07 Apr 2001 03:00:00 GMT  
 Scripting.FileSystemObject error!

Quote:

> I posted earlier thinking my changes to the database were the cause of
> my error.  Now I have narrowed the problem down to one line of code.  I
> have problems with the following function:
> ______________________
> Function getVariable(var)
>   Dim f, fso, str
>   on error resume next
>   getVariable = Null
>   'Set fso = Wscript.CreateObject("Scripting.FileSystemObject") //PROBLEM
> LINE!!!

 {snip}
> _________________
> This function simply reads a variable declaration from a file named by
> VARS which is set up like:
> VARIABLE_NAME variable value
> VARIABLE_NAME2 variable2 value
> and so on
> If  I comment out the line indicated above, it works as expected (I get
> an Object Required error).  If I leave that line in, I get:
> ___error message___
> The instruction at "0x6539a89a" referenced memory at "0x00000008".  The
> memory could not be "read".
> Click on OK to terminate the application
> ___end of error message___

> This is very important so any help you can give is greatly appreciated.

> A twist:  I have WORKING ASP pages that read files, and here is a
> snippet of code (on the same computer) that works 100%
>   set fs = CreateObject("Scripting.FileSystemObject")
  {snip}

> I am not very wise in the ways of scripting, but I believe the ASP page
> has a completely different engine, no?

> Thanks to anyone who can help!

The answer is as you allude; remove the Wscript. from the CreatObject,
i.e.

  Set fso = CreateObject("Scripting.FileSystemObject")

I don't know the reason why, just that this is how it works, even in
WSH.

Tom Lavedas
-----------
http://www.pressroom.com/~tglbatch/



Mon, 09 Apr 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. CreateObject("Scripting.FileSystemObject") Error

2. Set fs = CreateObject("Scripting.FileSystemObject")-error

3. another remote script error -filesystemobject

4. Scripting.FileSystemObject returns a file not found error

5. Error 429 with FileSystemObject / Scripting dll

6. Error using Scripting.FileSystemObject

7. CreateObject("Scripting.FileSystemObject") Error

8. Script Error Or No Script Error That Is The Question

9. FileSystemObject.FileCopy Multiple-step OLE DB operation generated errors

10. ASP Error in FileSystemObject after download of VBscript 5.5

11. Error using FileSystemObject

12. filesystemobject error

 

 
Powered by phpBB® Forum Software