From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

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,210 Views)
Solution
Accepted by topic author 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,188 Views)