zoegond

Autoit OO style

Oct 9th, 2024
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. ; main.au3 ; let obj;
  2. #include "Doubler.au3"
  3.  
  4. local $obj[]
  5. $obj["constructor"] = Doubler ;
  6. $obj["constructor"]($obj, 128) ; obj = new Doubler(128);
  7. MsgBox(0, "", $obj["Double"]($obj, 32)) ; alert(obj.Double(32));
  8. ;
  9. $obj["DoubleMe"]($obj) ; obj.DoubleMe();
  10. MsgBox(0, "", $obj["n"]) ; alert(obj.n);
  11.  
  12.  
  13.  
  14. ; Doubler.au3
  15. #include-once
  16. ; class Doubler {
  17.  
  18. func Doubler(byref $this, $n) ; constructor(n) {
  19. ; properties
  20. $this["n"] = $n ; this.n = n;
  21. ; methods
  22. $this["Double"] = DoublerDouble ; this.Double = DoublerDouble;
  23. $this["DoubleMe"] = DoublerDoubleMe ; this.DoubleMe = DoublerDoubleMe;
  24. endfunc ;
  25.  
  26. func DoublerDouble(byref $this, $x) ; Double(x) {
  27. return $x*2 ; return x*2;
  28. endfunc ; }
  29.  
  30. func DoublerDoubleMe(byref $this) ; DoubleMe() {
  31. $this["n"] = $this["Double"]($this, $this["n"]) ; this.n = this.double(this.n);
  32. endfunc ; }
  33.  
  34. ; }
Advertisement
Add Comment
Please, Sign In to add comment