Problem with get() function in LK script

  • Paul Gilman
  • Topic Author
More
10 Feb 2015 16:42 #3058 by Paul Gilman
Problem with get() function in LK script was created by Paul Gilman
One thing that appears to be different about SAM 2015.1.30 is that, when there is a variable referenced in LK that isn't used in a particular financial model, SAM returns and error and stops the script. The last version would just return a null value. For example: I get this error in my for code that is meant to write to a results file "[47]: error in call to 'get()': variable 'dscr' does not exist in this context" but previous versions would have just written "null." Clearly, there are ways around this but they're clunky. Any advice on this?
This was actually a bug in SAM 2014.11.24 that we fixed. In the earlier version, you could use the
get()
function with a variable that was not defined and still get a result. In other words, you could use
get()
with a variable whose name you mistyped, and you might not get an indication that the variable was invalid. Or, as in your example, you could use the
get()
function with a variable,
dscr
, with the residential or commercial financial model when that variable is only available for the PPA financial models.
The correct way to use the
get()
function with a variable that may not be defined under certain conditions is to use the
varinfo()
function to find out if the variable is defined. The
varinfo()
function returns null if a variable is not defined, and returns information about the variable if it is (name,units,group). For example:

Best regards,

Paul.

Please Log in or Create an account to join the conversation.

Moderators: Paul Gilman
Powered by Kunena Forum