Evgeny Shvarov · Sep 5, 2019 go to post

2. Sometimes you WANT and NEED to do the full scan. And my topic was about these cases. In some programming languages, we even can find reserve words for such, e.g. for each.

And again your comment is interesting and helpful and deserves another topic too.

Evgeny Shvarov · Sep 4, 2019 go to post

Thanks, Ed! Two remarks:

1. You mention iteration over resultset and introduce an example of iteration over array of columns cortege or record.

2. My question is not about getting values from arrays like list, locals, ppg, globals but what is better to use when you have a case of full scan over the array that in some cases lists are handier vs locals etc. 

Though the question of what array is better when you need to get values for keys is interesting too, maybe it's another good topic for discussion. Answering your statement here I agree for LB the choice for value by position if it's not a very large (huge) array, where the global is the only answer.

Evgeny Shvarov · Sep 3, 2019 go to post

I was looking at @David Underhill's code for Metrics project and decided that for one level global traversing his code style is the most readable:

    s database="" for {
        s database=$o(databases(database))
        q:database=""

...

}

And in general:

s iter="" for {

    s iter=$o(^array(iter)) q:iter=""

 // do something

}

So, use for instead of while for global traversing and this is readable and you never miss the next set is in while example.

Evgeny Shvarov · Sep 2, 2019 go to post

Cool. And what is better with while $listnext from the performance point of view - local variable or refer to a parameter every time?

Evgeny Shvarov · Sep 2, 2019 go to post

Very rich library and awesome package structure and ObjectScript styling. Perfect work, thank you Richard!

Evgeny Shvarov · Aug 29, 2019 go to post

Mine is faster ;)

ClassMethod RussianToEnglish(russian = "привет") As %String

{

set rus="абвгдезийклмнопрстуфхыэАБВГДЕЗИЙКЛМНОПРСТУФХЫЭьЬъЪ"

set eng="abvgdeziyklmnoprstufhyeABVGDEZIYKLMNOPRSTUFHYE"

set rus("ж")="zh"

set rus("ц")="ts"

set rus("ч")="ch"

set rus("ш")="sh"

set rus("щ")="shch"

set rus("ю")="yu"

set rus("я")="ya"

set rus("Ж")="Zh"

set rus("Ц")="Ts"

set rus("Ч")="Ch"

set rus("Ш")="Sh"

set rus("Щ")="Shch"

set rus("Ю")="Yu"

set rus("Я")="Ya"

set english=$tr(russian,rus,eng)



set wow=$O(rus(""))

while wow'="" {

set english=$Replace(english,wow,rus(wow))

set wow=$O(rus(wow))

}

return english

}

USER>w ##class(Example.ObjectScript).RussianToEnglish("Я вас любил: любовь еще, быть может, В душе моей угасла не совсем;"))
Ya vas lyubil: lyubov eshche, byt mozhet, V dushe moey ugasla ne sovsem;
USER>

Evgeny Shvarov · Aug 29, 2019 go to post

Hi Vivek!

If you want to check for all the required fields instead of checking it on %Save,  you better scan the class before %Save on the properties with required flag and check whether you have the value for it.

IMHO, this is the only way to show all the required fields at once.

Evgeny Shvarov · Aug 29, 2019 go to post

1 - Is there any plans to automatize the module.xml generation by using something like a Wizard?

Submit an issue?  More over, craft a module which supports that! And PR - it's a Community Package manager.

3 - Is it possible to run pre/post-install scripts as well? Kind of what installer classes do.

I think, this already in place. @Dmitry Maslennikov who contributed a lot will comment.

4 - Is also possible to use the module.xmlto provide a contextual root?

We maybe can use the code! Thanks! @Dmitry Maslennikov ?

Evgeny Shvarov · Aug 27, 2019 go to post

Perfect!

So, what is the setting of this parameter to export classes into:

/src/cls

folder?

Evgeny Shvarov · Aug 27, 2019 go to post

Sorry Vivek. My code provides you the Id of objExternalUser you save (possible create) above. It's 1).

It's not the latest inserted record. I thought you need:

I need RowId of inserted record.

Out of curiosity: why do you need the latest record?

Evgeny Shvarov · Aug 27, 2019 go to post

I agree. I don't know the reasons which caused to limit the MAXLEN to 50 characters... 

It steals months (if not more) of developers time to find out what was the bug and why this doesn't work because of MAXLEN=50;

Evgeny Shvarov · Aug 27, 2019 go to post

As I see in your code you already do some "error handling". So you can continue:

Change your code

Do objExternalUser.%Save()

to the following:

set stat=objExternalUser.%Save()

if $$$ISERR(stat) {

 #; error handling

 d $System.OBJ.DisplayError(stat)

}

HTH.

Out of curiosity - you have empty Try-Catch block. Why don't use it?

you could embrace your code into the following:

$$$TOE(objExternalUser.%Save())

And catch your error with status in catch then.

Evgeny Shvarov · Aug 27, 2019 go to post

Hi @Vivek Nayak!

Always check the status of %Save - it could result in an error. And I think this what was happened in your case.

90% of my "it doesn't save" with %Save caused by MAXLEN of %String property. %String property goes with MAXLEN=50 by default and it's often not enough. Check you have a such ;)