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.
Comments
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%StatusThe 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 ...
Here is a snippet of my arguments. I don't have them set to a default value which wouldn't be a bad practice to get into anyways.
Method Encrypt(pDirectory As %String, pDelete As %Boolean, pLog As %Boolean) As %Status
What's the Undefined config value on TEST and PROD:
zn"%SYS"set sc=##Class(Config.Miscellaneous).Get(.p)
write p("Undefined")On my production box it is a 0 and on my test system it is a 2.
Well I guess there IS a setting (thanks, @Eduard Lebedyuk!) ![]()
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.
There definitely does seem to be one! I went ahead and set the parameters in the Method and changed my test system to match my production system. Thank you guys so much!