You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While playing around and trying to use the iterate function with the global ^Settings on https://gettingstarted.intersystems.com/language-quickstarts/objectscript-quickstart/ I was getting an error, and using the $get function on line 20 fixed it for me. Would it not be a good practise to use the $get function on line 20 of ObjectScript.cls anyways.
Thanks.
The text was updated successfully, but these errors were encountered:
Thanks for bringing this up. The current code sample is meant as a simple illustration, but indeed you can trip over this error if there is an additional subscript (which dwells just a little outside of the sample scenario).
Assigning to @isc-mlo who owns this part of the documentation for his consideration.
To other developers that are learning ObjectScript and reading this: we don't want to teach anyone to "use the $get function everywhere, just to be safe." In this QuickStart:
Using $get is not necessary when calling the Iterate() method as it is written, since it's looping through ^testglobal..
Changing Iterate() to loop through the ^Settings global is a fine thing to try. Typically, a global with multiple levels of subscripts would be traversed using nested$order loops, one per level (which as @bdeboe said, is beyond the focus of this QuickStart). When looping through only the first level of ^Settings, using $get will prevent the <UNDEFINED> error for the "Auto1" and "Auto2" subscripts. Or, do the following in the Web Terminal and run Iterate() without the $get: set ^Settings("Auto1") = "Mustang", ^Settings("Auto2") = "Charger"
While playing around and trying to use the iterate function with the global ^Settings on https://gettingstarted.intersystems.com/language-quickstarts/objectscript-quickstart/ I was getting an error, and using the $get function on line 20 fixed it for me. Would it not be a good practise to use the $get function on line 20 of ObjectScript.cls anyways.
Thanks.
The text was updated successfully, but these errors were encountered: