What to use instead of IsDefined()

I have a legacy site I’m moving to Lucee that tests for the existence of a cfc called “Page”. I was checking the syntax and saw that IsDefined() is deprecated.

What should I use instead of If (IsDefined(“Page”) is false ) …?

Mike Kear
Windsor, NSW, Australia

@mikek Please see those topics related to isdefined

Thank you [cfmitrah] those are of interest, but still dont give me an answer. I’m testing for the existence of a cfc. “Page” is an object so if i try to use structKeyExists, it will throw an error because it’s not a struct and there wont be any key.

In fact i think isDefined() is exactly the right function for that. However it’s deprecated i need to find a replacement for it.

@mikek does isNull() not work?


Re: “the existence of a cfc” do you mean whether an object named Page has been instantiated from Page.cfc? If so, objects are in the Variables scope, so this should work:

Page = new Page();
  label="StructKeyExists(Variables, 'Page')",
  var=StructKeyExists(Variables, 'Page')
); // true

Thank you Lionel, I think you have hit the nail on the head here.

Mike Kear
Windsor, NSW, Australia

1 Like