cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

unshift() autocomplete bug

unshift() autocomplete bug

Bug: The code completion for Object.inObjects, centerObjects and outObjects shows an unshift method. It does not really make sense, I guess this is a copy/paste error from the Array interface.

6741-codecompletionerror.jpg

Suggestion: Since the InObjectArray and friends seem to be derived from Array anyway, I was thinking it would be cool to have an indexOf function so we can get rid of the confusing ipopno and opipno:

Object source = model.find( "Source1" );
Object queue = model.find( "Queue34" );
int ipopno = source.outObjects.indexOf( queue );
_ASSERT( ipopno > 0 && source.outObjects[ ipopno ] == queue );

int opipno = queue.inObjects.indexOf( source );
_ASSERT( opipno > 0 && queue.inObjects[ opipno ] == source );
1 Comment
philboboADSK
Autodesk

Yes, the unshift() method in the autocomplete looks like a bug.

As for your ipopno() suggestion: adding an indexOf() is a good suggestion that we will add to the dev list, but ipopno() and opipno() don't do what your suggestion does.

ipopno() tells you the output port number that is connected to the input port of the object. Your suggestion gets you the opposite: it tells you about what port number is connected to another object (the return value is a port number on your object instead of the other object). Your example code also has different inputs (two objects) than ipopno() and opipno() (one object and a port number).

The following image shows how ipopno() works in 4 script windows:

Image.png

The upper-left script shows ipopno()'s usage. It tells you that Queue3 is connected to the third output port of Source4 (the queue's 4th input object).

The bottom-left script shows essentially what the command does, which is calling all O(1) lookup operations. No loops are necessary.

The upper-right script shows what the replacement for ipopno() would look like using the proposed indexOf() command, which actually shows why the command is named ipopno() as shown in the annotations. This is definitely more readable and less confusing than ipopno().

The bottom-right script shows what that replacement would essentially be, which includes a lookup that requires a loop. Thus, it isn't a perfect replacement for ipopno(), but it still could be a useful command none-the-less.

Can't find what you're looking for? Ask the community or share your knowledge.

Submit Idea