How can I state in VBScript scripts?

What is a good way to use claims in VBScript scripts?

Are there any built-in functions for it or should it be emulated? What is the practice?

One application should test Nothing objects during development.

+4
source share
2 answers

The quick answer (for others that he might need) is to define this function: Rosetta Code :

  sub Assert( boolExpr, strOnFail ) if not boolExpr then Err.Raise vbObjectError + 99999, , strOnFail end if end sub 

Vocation:

  Set obj2 = Nothing Assert Not obj2 Is Nothing, "obj2 is Nothing!" 

Conclusion:

  someScript.vbs(17, 3) (null): obj2 is Nothing! 
+6
source

Unfortunately, I do not think that VBScript has something built-in. You will need to define your own Assert method and possibly use the pre-processor script assembly or something to remove them when making a copy of your script release. (In fact, deleting - at least commenting out - calling Assert better than just making the body of Assert do nothing in the released code.)

+3
source

Source: https://habr.com/ru/post/1301908/


All Articles