result = mSelect->SetSelectedIndex(aSelectedIndex);
nsCOMPtr<nsIPresState> presState; nsCOMPtr<nsISupportsArray> value; res = GetPresState(getter_AddRefs(presState), getter_AddRefs(value)); if (NS_SUCCEEDED(res) && !presState) { return NS_OK; }    PRBool doesExist = PR_FALSE; if (!value) { res = NS_NewISupportsArray(getter_AddRefs(value)); } else { doesExist = PR_TRUE; }  if (NS_SUCCEEDED(res) && value) {    PRUint32 count = 0; value->Count(&count);    if (!isMultiple) { value->Clear(); count = 0; }   nsCOMPtr<nsISupportsPRInt32> thisVal; res = nsComponentManager::CreateInstance(NS_SUPPORTS_PRINT32_PROGID, nsnull, NS_GET_IID(nsISupportsPRInt32), (void**)getter_AddRefs(thisVal)); if (NS_SUCCEEDED(res) && thisVal) { res = thisVal->SetData(aIndex); if (NS_SUCCEEDED(res)) { PRBool okay = value->InsertElementAt((nsISupports *)thisVal, count); if (!okay) res = NS_ERROR_OUT_OF_MEMORY; } }    if (!doesExist) { presState->SetStatePropertyAsSupports("selecteditems", value); } }
nsHTMLOptionCollection::SetSelectedIndex(PRInt32 aSelectedIndex){  nsresult result = NS_ERROR_UNEXPECTED;  if (mSelect) {    if (mDirty) {      GetOptions();    }    result = mSelect->SetSelectedIndex(aSelectedIndex);  }  return result;}