Remove the List permission from TablePermission_Loaded

I have a custom file with the name
mycustomfile.php

I would like to remove the List permission for custom file

I try the code as -
if (CurrentUserLevel() == “2” && CurrentTable()->TableName == “mycustomfile.php”)
$this->setCanList(FALSE);

But I got the error as
Notice: Trying to get property of non-object in C:\wamp\www*********\phpfn15.php on line 7182

There is no database table for a custom file, you may try CurrentPage() instead of CurrentTable().