intersystems-community / ideas-and-innovations

InterSystems Developer Community Ideas and Requests for Innovative Solutions with InterSystems IRIS
MIT License
5 stars 0 forks source link

Introduce for each for global traversing #32

Closed evshvarov closed 2 years ago

evshvarov commented 4 years ago

instead of:

set key="" for {
set key=$O(^array(key)) q:iter=""
// do something
}

introduce:


foreach key in ^array {
// do something
}
rcemper commented 3 years ago

do you look for something like this ?

define foreach(%key,%arr,%do) set %key=$o(%arr("")) for set %key=$o(%arr(%key)) quit:%key="" do %do

using it: a $$$foreach(key,^rcc(27),b) quit b zwrite @$zr,! quit

evshvarov commented 3 years ago

Looks as what I'm looking for. Ideally to have a zpm module with all these macro related to Global traversing

On Tue, Feb 16, 2021 at 1:29 PM rcemper notifications@github.com wrote:

do you look for something like this ?

define foreach(%key,%arr,%do) set %key=$o(%arr("")) for set

%key=$o(%arr(%key)) quit:%key="" do %do

using it: a $$$foreach(key,^rcc(27),b) quit b zwrite @$zr,! quit

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/intersystems-community/ideas-and-innovations/issues/32#issuecomment-779742986, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAVHEP2Z3BPQY4UCULRZRGLS7JCJLANCNFSM4ITCKCJA .

rcemper commented 3 years ago

Just a minor adjustment:

define foreach(%key,%arr,%do) set %key="" for set

%key=$o(%arr(%key)) quit:%key="" do %do

I'm trying it just now also as ZFOREACH()  in %ZLANGF00. It my take some time.

Robert

Am 16.02.2021 um 12:11 schrieb Evgeny Shvarov:

Looks as what I'm looking for. Ideally to have a zpm module with all these macro related to Global traversing

On Tue, Feb 16, 2021 at 1:29 PM rcemper notifications@github.com wrote:

do you look for something like this ?

define foreach(%key,%arr,%do) set %key=$o(%arr("")) for set

%key=$o(%arr(%key)) quit:%key="" do %do

using it: a $$$foreach(key,^rcc(27),b) quit b zwrite @$zr,! quit

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub

https://github.com/intersystems-community/ideas-and-innovations/issues/32#issuecomment-779742986, or unsubscribe

https://github.com/notifications/unsubscribe-auth/AAVHEP2Z3BPQY4UCULRZRGLS7JCJLANCNFSM4ITCKCJA .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/intersystems-community/ideas-and-innovations/issues/32#issuecomment-779766908, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHOKEJL2OR6DLY64DRRKXDLS7JHF3ANCNFSM4ITCKCJA.

rcemper commented 3 years ago

It's done. available in OEX+ZPM for COS and ISOS FOREACH for ObjectScript

rcemper commented 3 years ago

same as issue #31

evshvarov commented 2 years ago

Closing as it is done