02-28-2018 10:18 AM
Dear NI AE,
currently I am facing a problem when I am trying to include a class file in DIAdem 2017. The procedure am using to include the class-file is the following:
Sub Include(sInstFile)
Dim f, s, oFSO
Set oFSO = CreateObject("Scripting.FileSystemObject")
On Error Resume Next
If oFSO.FileExists(sInstFile) Then
Set f = oFSO.OpenTextFile(sInstFile)
s = f.ReadAll
f.Close
ExecuteGlobal s
End If
End Sub
When I Include the class file that had ben saved in DIAdem 2012 the inclusion works just fine. Using the exact same file saved in DIAdem 2017 causes an Error.
I have attached an perfect example for you to reproduce the Error (Variable is undefined: 'Condition'). Defining the Variable (Dim Condition) does not help. The Sub Include(...) simply has problems with the class-file saved in DIAdem 2017.
Looking at the saved file one can easily see the difference. The filesize of the saved file is smaller when I save it in DIAdem 2012 (DIAdem 2012 = 2KB; DIAdem 2017 = 4KB). I guess the additonal data causes the problem.
Can you find out where the difference in the filesize is coming from? And what additional data does DIAdem 2017 store in the files?!
Thank you and kind regards
Dani
Solved! Go to Solution.
02-28-2018 11:35 AM
This based on the file encoding.
It is ansi versus Unicode.
Youcan change your file encoding back to ansi if you pick
File -> Change Encoding -> Unicode To Ansi
in module script.
Afterwards your script will work again.
Set f = oFSO.OpenTextFile(sInstFile, 1, -1)
would also do the job but you need to figure out the file encoding by reading the firstbytes.
At the end it is easier to use Scriptinclude like in your example which does the determination stuff for you.
03-01-2018 02:45 AM
Dear AndreasK,
thanks a million for the explanation and the swift solution! You're the man!
Kind regards
Dani 😉