Interactive PowerBasic Forum

IT-Consultant: Charles Pegge => OxygenBasic Examples => Topic started by: Charles Pegge on February 16, 2025, 06:44:43 AM

Title: ForEach Macro
Post by: Charles Pegge on February 16, 2025, 06:44:43 AM
A very simple implementation of ForEach:

def ForEach
===========
scope
int i
for i=lbound(%1) to ubound(%1)
  %2
next
end scope
end def

'TEST
'====
int a[2]
ForEach a { a[i]=i }
ForEach a { print a[i] }
'ForEach obj { obj[i].id=i }