Vbscript static class variables / methods?

Is there a way to have one variable for each class in vbscript?

If this is not the best way to imitate this? Prefix of a global variable declared next to a class?

Is there also a way to declare static / class methods (for a static constructor) or force a function prefix?

+4
source share
1 answer

In languages ​​that support class / static data or methods, you can

  • bind / bind data or methods explicitly with a set of objects defined by a class. Thus, you can have Customer.Count and Product.Count, and a simple counter (or @@ Count) in the client code will get access to the correct number.
  • use such data or a method without having an instance of the class (for now).

VBScript does not support static data or methods. You should use global data or functions / subtitles and do the association in your mind (perhaps with a little help from the naming convention). Access to these "static" = global elements without an object is trivial, but obviously should be done with care.

You can embed one or more singleton objects or code references (GetRef ()) in your objects to bind them closer to the class, but this will increase the size of the instances.

+3
source

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


All Articles