FoxInCloud
Error: SCRIPTING.FILESYSTEMOBJECT
On the server (not in local mode) I get the new following error:
error # 1733 ("SCRIPTING.FILESYSTEMOBJECT class definition not found")
My code is:
Fso = CREATEOBJECT ("Scripting.FileSystemObject")
this happens with COM/OLE classes; not sure whether it's a VFP or a Windows bug.
The workaround I've found it to instantiate an object of this OLE class at server startup, store it into a _screen.property
or a public
variable, and re-use this instance to avoid re-creating new instances over and over.
Thank you, I'm trying a public variable
It's fine (with a public variable) !
I advise to create a function:
function oScriptingFSO as Scripting.FileSystemObject
local cType
cType = vartype(m.goScriptingFSO)
if m.cType == 'U'
public goScriptingFSO
endif
if m.cType # 'O'
goScriptingFSO = createObject('Scripting.FileSystemObject')
endif
return m.goScriptingFSO
endfunc
In your code:
local loScriptingFSO as Scripting.FileSystemObject
loScriptingFSO = oScriptingFSO()
loScriptingFSO.method()
…
I advise to create a function:
Because you also use this statement, in the FIC code ?
just a programming hint; using a function:
- isolates the code and the variable name; eg., if you prefer to have less public variables, you could store each reference to a COM object into a property of a public object:
function oScriptingFSO as Scripting.FileSystemObject
local cType
cType = vartype(m.goCOMs)
if m.cType == 'U'
public goCOMs
endif
if m.cType # 'O'
goCOMs = createObject('Empty')
endif
if !type('m.goCOMs.oScriptingFSO') == 'O'
addProperty(m.goCOMs, 'oScriptingFSO', createObject('Scripting.FileSystemObject'))
endif
return m.goCOMs.oScriptingFSO
endfunc
- instantiates
'Scripting.FileSystemObject'
only when needed - reinstantiates
'Scripting.FileSystemObject'
if aborted or killed