This might be a really dumb question, but here we go:
I’m trying to address the children of a variantDictionary object iteratively via a loop.
The idea is…
VBScript
Set ParentObject = <<VariantDictionaryPath>>
For i = 0 To 7
Child = Concat(Probe, i)
myArray(i) = ParentObject.Child
Next
I cannot get the code to recognize “Child” in the above code as a variable referencing the correct key instead of literally interpreting it as “Child”.
I think this comes down to a fundamental issue with self-teaching VBScript, but regardless I’m hitting a wall as I don’t know what to google for relevant help.
Also I can’t seem to find any functionality similar to Object.CountChildren or similar. Is there even such functionality in the world of Biomek VBScripting?
Unfortunately I didn’t find any answer. I just used ChatGPT to help me hardcode everything. I’m positive that there’s some way to do this type of scripting, I just haven’t had the time to experiment and research it.
I had this snippit shared with me trying to resolve a different problem - I think there’s probably a way to modify this logic to work for pulling values from object children. However, loading them back in be problematic.
world.globals.propertychanger.setglobal "pg", world.globals.pausegenerator
message = "" ' Initialize the message variable
Set toplevel = world.Volatile ' Assign the desired object to toplevel
' Iterate through the keys at the first level under "toplevel"
for each keyName in toplevel
keyValue = ""
' Check if the key has a value and retrieve it
if IsObject(toplevel(keyName)) or IsArray(toplevel(keyName)) then
keyValue = "<complex type>"
elseif IsNull(toplevel(keyName)) then
keyValue = "null"
else
keyValue = toplevel(keyName)
end if
' Concatenate each key name and value to the message, with a delimiter (e.g., comma)
if message = "" then
message = keyName & ": " & keyValue
else
message = message & ", " & keyName & ": " & keyValue
end if
next
' Display the concatenated message
pg.BtnPromptUser(message), SafeArray("OK"), "OK"
This script is used to debug variables in the world.volatile path, but point it towards something like Object.Index and you could build an array for n children.