1
$\begingroup$

Suppose a user inputs a list of CellObject-s to operate on. How might one check these objects to determine if they actually belong to the EvaluationNotebook? Here is a given sample:

cells = Cells[CellStyle->"Input"]
$\endgroup$

1 Answer 1

1
$\begingroup$

You can do this to check whether they all belong there:

DeleteDuplicates[ParentNotebook /@ cells] === { EvaluationNotebook[] }
$\endgroup$
3
  • 1
    $\begingroup$ so if i get True they all belong and False otherwise? It's for error checking. $\endgroup$ Commented Jan 19, 2023 at 23:43
  • 1
    $\begingroup$ @JulesManson the key is ParentNotebook[_CellObject], this gives you information about cell's notebook, then you can do whatever you need. I chose this way, it should do the job but feel free to do whatever you wish. $\endgroup$
    – Kuba
    Commented Jan 20, 2023 at 8:15
  • $\begingroup$ no, this is perfect. i just didnt expect it to be so easy. thanks again. :) $\endgroup$ Commented Jan 21, 2023 at 0:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.