Jump to content

Object variable names


justsomeguy

Recommended Posts

I have a situation where I need to determine the instantiated variable name of an object. I have several objects set up, all just generic objects, and I've got a recursive function that is going through the collection of objects and examining each one. All objects are properties of a root object called cmi, here are a couple examples:cmi.core.score.mincmi.core.total_timecmi.core.lesson_modecmi.core.exitcmi.core.session_timecmi.suspend_datacmi.launch_dataSome of these are objects and others are scalar values (cmi.core.score is an object, cmi.core.score.min is a scalar value, a property). I've got a function where initially I pass the entire cmi object, and the function goes through the properties on that object and checks each one, and recurses for child objects. I'm looking for a way for this function to identify, for example, that the current thing it is looking at is cmi.core.score.raw, or cmi.suspend_data, or whatever the specific object or property is. I've looked into the standard properties that objects have but I don't see something that fits. Has anyone used something like this before?

Link to comment
Share on other sites

Have you looked at the for[each] function?

var cmi = [];cmi.suspend_data = "somevalue";cmi.launch_data = "test";for(x in cmi){   alert(x + " = " + cmi[x]);}

Link to comment
Share on other sites

Yeah, I've seen that. But with the recursion, if the parent object is cmi.core.score.min and I'm looking at min, x is just min, it's not cmi.core.score.min. I'll probably just have to pass along the full name with the function.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...