DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Importing only part of a file

Solved!
Go to solution

Hello,

 

I have a main script importing two scripts and running their main function in a for loop. I have several problems with that

 

Call ScriptInclude("ScriptA.VBS")

Call ScriptInclude("ScriptB.VBS")

 

For i = 1 To Data.Root.ChannelGroups.Count  

    Call analysisA(True)

    Call analysisB(True)

Next

 

I believe I need the ScriptInclude function, because I want to send a parameter to the analysis function. When doing imports like this, however, everything is imported from the scripts. I have a cleanup() function in both of them with a slightly different functionality and ScriptInclude causes, that even in the analysisA function call the cleanup from the ScriptB gets called, which causes an error.

 

Coming from Python, I wish there was functionality like this:

from ScriptA.VBS import analysisA

from ScriptB.VBS import analysisB

 

analysisA()  - now working correctly, because local cleanup function gets called

analysisB()

 

Or:

import ScriptA.VBS as ScriptA

import ScriptB.VBS as ScriptB

ScriptA.analysisA()  - this way I don't even have to name analysisA and analysisB differently, just use analysis name

ScriptB.analysisB()

 

Or:

from ScriptA.VBS import analysis as analysisA - this way I don't have to name analysisA and analysisB differently

from ScriptB.VBS import analysis as analysisB

 

The current functionality is basically equivalent to:

from ScriptA.VBS import *

from ScriptB.VBS import *

which is discouraged, because it can cause problems I encountered in DiaDEM.

0 Kudos
Message 1 of 2
(2,206 Views)
Solution
Accepted by topic author SeryDavid

There is a scope

option explicit

Call ScriptInclude("ScriptA.VBS", "A")
Call ScriptInclude("ScriptB.VBS", "B")

LogfileDel

Call A.analysisA(True)
Call B.analysisB(True)

which will call

A: analysis called
A: Cleanup called
B: analysis called
B: Cleanup called

does this match your needs?

0 Kudos
Message 2 of 2
(2,197 Views)