Page 1 of 1

ForEach MyList() As *MyListElement

Posted: Thu May 09, 2013 6:26 pm
by Josh
I think the subject is saying all.

Re: ForEach MyList() As *MyListElement

Posted: Thu May 09, 2013 8:24 pm
by uwekel
+1!

Or you can use the syntax like in Python:

Code: Select all

ForEach *pointer.MyListStruct In MyList()
In the meantime i use a macro:

Code: Select all

Macro Item(Object, ListOrMap)
  ListOrMap
  Object=ListOrMap
EndMacro

Structure Person
  Name.s
  Age.i
EndStructure

NewList Persons.Person()

AddElement(Persons())
Persons()\Name = "Jim"
Persons()\Age = 30

ForEach Item(*p.Person, Persons())
  Debug *p\Name + " is " + *p\Age + " years old"
Next
I put the Macro into a resident file so it is available all the time.

Best regards,
Uwe

Re: ForEach MyList() As *MyListElement

Posted: Fri May 10, 2013 9:06 am
by Joris
+1 and
As I already had a request and don't wont to create an endless list... I think this one adds up here nice.

ForEach GadgetType()

(case #PB_GadgetType_Button : change color, change text (language), change center etc.)