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.

58 lines
1.8 KiB

  1. //***************************************************************************
  2. //This script tests the manipulation of context values, in the case that the
  3. //context value is an array type
  4. //***************************************************************************
  5. var Context = new ActiveXObject ("WbemScripting.SWbemNamedValueSet");
  6. Context.Add ("n1", new Array (1, 20, 3));
  7. var arrayValue = new VBArray (Context("n1").Value).toArray();
  8. var str = "The initial value of n1 is [1,20,3]: {";
  9. for (var i = 0; i < arrayValue.length; i++)
  10. {
  11. str = str + arrayValue[i];
  12. if (i < arrayValue.length - 1)
  13. str = str + ", ";
  14. }
  15. str = str + "}"
  16. WScript.Echo (str);
  17. WScript.Echo ("");
  18. //Verify we can report the value of an element of the context value
  19. var v = new VBArray (Context("n1").Value).toArray ();
  20. WScript.Echo ("By indirection n1[0] has value [1]:",v[0]);
  21. //Verify we can set the value of a single named value element
  22. Context("n1")(1) = 14;
  23. WScript.Echo ("After direct assignment n1[1] has value [14]:",
  24. (new VBArray(Context("n1").Value).toArray ())[1]);
  25. //Verify we can set the value of a single named value element
  26. v[1] = 11;
  27. Context("n1").Value = v;
  28. WScript.Echo ("After direct assignment n1[1] has value [11]:",
  29. (new VBArray(Context("n1").Value).toArray ())[1]);
  30. //Verify we can set the value of an entire context value
  31. Context("n1").Value = new Array (5, 34, 178871);
  32. WScript.Echo ("After direct array assignment n1[1] has value [34]:",
  33. (new VBArray(Context("n1").Value).toArray ())[1]);
  34. arrayValue = new VBArray (Context("n1").Value).toArray();
  35. str = "After direct assignment the entire value of n1 is [5,34,178871]: {";
  36. for (var i = 0; i < arrayValue.length; i++)
  37. {
  38. str = str + arrayValue[i];
  39. if (i < arrayValue.length - 1)
  40. str = str + ", ";
  41. }
  42. str = str + "}"
  43. WScript.Echo (str);
  44. WScript.Echo ("");