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.

75 lines
1.5 KiB

  1. On Error Resume Next
  2. while true
  3. Set context = CreateObject("WbemScripting.SWbemNamedValueSet")
  4. 'Try to add a null
  5. context.Add "J", null
  6. Set namedValue = context.Add("fred", 23)
  7. context("fred").Value = 12
  8. context.Add "Hah", true
  9. context.Add "Whoah", "Freddy the frog"
  10. context.Add "Bam", Array(3456, 10, 12)
  11. 'Test collection behavior
  12. for each value in context
  13. if (IsNull (value)) Then
  14. WScript.Echo value.Name, "NULL"
  15. else
  16. if (IsArray (value)) Then
  17. Dim str
  18. str = value.Name & " {"
  19. V = value.Value
  20. for x=LBound(value) to UBound(value)
  21. if x <> LBound(value) Then
  22. str = str & ", "
  23. End If
  24. str2 = V(x)
  25. str = str & str2
  26. Next
  27. str = str & "}"
  28. WScript.Echo str
  29. Else
  30. WScript.Echo value.Name, value
  31. End if
  32. end if
  33. next
  34. if Err <> 0 Then
  35. WScript.Echo Err.Description
  36. Err.Clear
  37. End if
  38. wend
  39. 'Test Count property
  40. WScript.Echo "There are", context.Count, "elements in the context"
  41. 'Test Removal
  42. context.Remove("hah")
  43. WScript.Echo "There are", context.Count, "elements in the context"
  44. 'Test Removal when element not present (NB: context names are case-insensitive)
  45. context.Remove("Hah")
  46. WScript.Echo "There are", context.Count, "elements in the context"
  47. 'Iterate through the names
  48. WScript.Echo ""
  49. WScript.Echo "Here are the names:"
  50. WScript.Echo "=================="
  51. for each value in context
  52. WScript.Echo value.Name
  53. Next
  54. 'Test array access and default property of NamedValue
  55. WScript.Echo ""
  56. WScript.Echo "Whoah element of context = ", context("Whoah")