Question
· Mar 30, 2023

Intersystems Environment Requiring Values in Parameters

Hey all,

I have been creating a class to handle file encryption by using GPG keys. I pushed my code out today and my encrypt and decrypt methods weren't working. About a half an hour later in troubleshooting I found out that it needed to be a syntax change. My method has three parameters to it. Examples below:

This is how I was calling it in the test system with no issues:

do gpg.Encrypt()

This is how I was having to call it in my production system to work with no issues:

do gpg.Encrypt("","","")

If I was to enter in my production environment do gpg.Encrypt() I would just get an undefined due to it not interpreting my variables.

It's like on my test system it infers my arguments if they're null, but on my production system they need to be passed in order to be interpreted.

Is there an environment variable in Intersystems that I might be missing that would cause this behavior? This is just out of pure curiosity and isn't a true need, but I just found it interesting/peculiar.

Product version: HealthShare 2017.2
$ZV: Cache for Windows (x86-64) 2017.2.2 (Build 865_3_20793U)
Discussion (6)2
Log in or sign up to continue

What does your method's argument list look like? If it's something like this:

Method Encrypt(pVarA As %String = "", pVarB As %String = "", pVarC As %String = "") As %Status

The pVar* variables above should automatically default to empty strings when the method is called as provided in your first example.

I'm not aware of any system setting that would affect the behavior of unsupplied values for method arguments when they're not defined with an initial value (unlike those in my snippet above).

That doesn't mean that there isn't one, though ...

Well I guess there IS a setting (thanks, @Eduard Lebedyuk!) laugh

The parameter Undefined specifies the behavior when ObjectScript attempts to fetch the value of a variable that has not been defined. The value of Undefined may be 0, 1, or 2:

  • 0 - Always throw an <UNDEFINED> error. (default)
  • 1 - If the undefined variable has subscripts, return a null string, but if the undefined variable is single-valued, throw an <UNDEFINED> error.
  • 2 - Always return a null string.

You can change that setting in System Administration | System Configuration | Additional Settings | Compatibility.