Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
2.7 KiB

  1. //***************************************************************************
  2. //This script tests the manipulation of qualifier values, in the case that the
  3. //qualifier is an array type
  4. //***************************************************************************
  5. var locator = WScript.CreateObject ("WbemScripting.SWbemLocator");
  6. var service = locator.ConnectServer (".", "root/default");
  7. var Class = service.Get();
  8. Class.Path_.Class = "ARRAYQUAL00";
  9. var Qualifier = Class.Qualifiers_.Add ("q", new Array (1, 2, 33));
  10. //****************************************
  11. //First pass of tests works on non-dot API
  12. //****************************************
  13. WScript.Echo ("");
  14. WScript.Echo ("PASS 1 - Use Non-Dot Notation");
  15. WScript.Echo ("");
  16. var str = "After direct assignment the initial value of q is {";
  17. var value = new VBArray (Qualifier.Value).toArray ();
  18. WScript.Echo ("The length of the array is", value.length);
  19. for (var x=0; x < value.length; x++) {
  20. if (x != 0) {
  21. str = str + ", ";
  22. }
  23. str = str + value[x];
  24. }
  25. str = str + "}";
  26. WScript.Echo (str);
  27. //Verify we can report the value of an element of the qualifier value
  28. var v = new VBArray (Qualifier.Value).toArray ();
  29. WScript.Echo ("By indirection the third element of q has value:",v[2]);
  30. //Verify we can report the value through the collection
  31. var w = new VBArray (Class.Qualifiers_("q").Value).toArray ();
  32. WScript.Echo ("By direct access the first element of q has value:", w[2]);
  33. //Verify we can set the value of a single qualifier value element
  34. var p = new VBArray (Qualifier.Value).toArray ();
  35. p[1] = 345;
  36. Qualifier.Value = p;
  37. var value = new VBArray (Qualifier.Value).toArray ();
  38. WScript.Echo ("After indirect assignment the second element of q has value:", value[1]);
  39. //Verify we can set the value of an entire qualifier value
  40. Qualifier.Value = new Array (5, 34, 178871);
  41. var str = "After direct assignment the initial value of q is {";
  42. var value = new VBArray (Class.Qualifiers_("q").Value).toArray ();
  43. WScript.Echo ("The length of the array is", value.length);
  44. for (var x=0; x < value.length; x++) {
  45. if (x != 0) {
  46. str = str + ", ";
  47. }
  48. str = str + value[x];
  49. }
  50. str = str + "}";
  51. WScript.Echo (str);
  52. //Verify we can set the value of a property array element using the "dot" notation
  53. // NB - Note that using [] rather than () does NOT work as JScript appears to first
  54. // interpret this as a request to retrieve Qualifier.Value; the assignment is therefore
  55. // only made on the local temporary copy of the value
  56. var Qualifier = Class.Qualifiers_("q");
  57. Qualifier.Value(2) = 8889;
  58. WScript.Echo ("By direct access the second element of p1 has been set to:", (new VBArray(Class.Qualifiers_("q").Value).toArray())[2]);
  59. Class.Put_ ();