09-27-2013 05:28 PM
I am in a REAL pickle here and need some HELP......
I get a permissions error message when I try and run my scripts more than once with out closing Diadem 2011.
Call scriptinclude ("D:\_Calterm_Configuration_Files\Technical_Information\DIAdem_Scripts\Importing Multiple Data Logs_CaltermIII_Local.VBS")
Error is around this portion of script:
'-------------------------------------------------------------------------------------
'******* GetFilePaths() *** *** NEW Function ***
'-------------------------------------------------------------------------------------
Function GetFilePaths(DefaultDir, ExtFilter, MultipleDir, Msg)
Dim i, k, f, fso, iMax, FileListPath, StartIdx, CurrFiles, FileList
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Promt the User to select the ASCII files to load with a File Dialog
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
FileListPath = AutoActPath & "FileDlgList.asc"
Set fso = CreateObject("Scripting.FileSystemObject")
StartIdx = 0
ReDim FileList(0)
Do ' Until (DlgState = "IDCancel")
Call FileNameGet("ANY", "FileRead", DefaultDir, ExtFilter, FileListPath, 1, Msg)
IF (DlgState = "IDCancel") THEN Exit Do
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Read in the saved list of file(s) selected in the File Dialog into FileList()
**** This next line is where the ERROR happens *******
Set f = fso.OpenTextFile(FileListPath, 1, True) ' f.ReadAll returns file contents
CurrFiles = Split(vbCRLF & f.ReadAll, vbCRLF) ' turn file lines into an array
f.Close ' close the file
iMax = UBound(CurrFiles)
IF iMax > 0 AND Trim(CurrFiles(iMax)) = "" THEN
iMax = iMax - 1
ReDim Preserve CurrFiles(iMax)
END IF
Call BubbleSort(CurrFiles) ' sort the array of file names alphabetically
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Append current file dialog selection(s) to any previous file dialog selection(s)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
IF iMax < 1 THEN iMax = 0
ReDim Preserve FileList(k + iMax)
FOR i = 1 TO iMax
k = k + 1
FileList(k) = CurrFiles(i)
NEXT ' i
IF MultipleDir <> TRUE THEN Exit Do ' forces only 1 dialog, good if all desired files are in the same folder
Loop ' Until (DlgState = "IDCancel")
GetFilePaths = FileList
End Function ' GetFilePaths()
266 6:18:34 PM Error:
Error in <NoName(1).VBS> (Line: 8, Column: 1):
Error in <Importing Multiple Data Logs_CaltermIII_Local.VBS> (Line: 140, Column: 5):
Permission denied
I can send the script and file I am loading if that would help.
Solved! Go to Solution.
09-29-2013 08:38 PM
And if I run the script manually it will always run and pass successful. As long as I don't call the script from another source I am ok.
09-30-2013 04:31 PM
Jcheese,
I understood that if you call this script within DIAdem you don't get any error, however, when you run that script from another source (with DIAdem opened) for the second time you get the error, right?
If this is the case, I think it might be that the file haven't close correctly in the script. Could you upload the script file?
Carmen C.
10-04-2013 09:34 AM
Hi Jcheese,
Let's try to sidestep that error by not having to read any text file at all. Try this instead to get the list of selected file paths in the "FielPaths" array:
Call FileNameGet("Any", "FileRead", StartPath, FileExts, "Nul", True, DlgTitle) FilePaths = Split("|" & FileDlgFileName,"|")
Brad Turpin
DIAdem Product Support Engineer
National Instruments
10-07-2013 01:53 PM
Ok, I played around some more with this and found that if I used global dim( autoactpath) and then specificed what that was set to. All my problems went away. I just added it to the begining of my first script and I have 15 different scripts I run from the one dialog box and now all the little glitchs i was just putting up with went away. anything that I used autoactpath with was fixed.
thanks for the help.