DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Check if DIAdem script started directly

Solved!
Go to solution

Hello,

is there a way to check if DIAdem script started directly?

 

In Python there is:

if __name__ == "__main__":
    main()

 

With this functionality I could separate functionality for the script when it is imported by another script and when it is run directly.

0 Kudos
Message 1 of 2
(2,577 Views)
Solution
Accepted by SeryDavid

There is no direct way but you could use SubSequence and some error handling.

 

bMain()
sub bMain()
  on error resume next
  call SubSequence() : if 0 = err.number then exit sub
  on error goto 0
  
  MsgBox "Execute main"
end sub

Here are two example scripts to check

a.vbs

Option Explicit
scriptinclude currentScriptPath & "b.vbs"

call b()

b.vbs

Option Explicit

sub b()
  MsgBox "b called"
end sub

bMain()
sub bMain()
  on error resume next
  call SubSequence() : if 0 = err.number then exit sub
  on error goto 0
  
  MsgBox "Execute main"
end sub

 

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