Menu

How to iterate over several edit-fields?

devnull
2024-01-18
2024-01-19
  • devnull

    devnull - 2024-01-18

    I have a GUI with up to 30 individual edit-fields. Is there a way to iterate over all of them if they share the same prefix name and an numeric ID? Is there an array object containing all of the items of a specific type?

     
  • Stefan Zieker

    Stefan Zieker - 2024-01-19

    You can use the eval() function. If you have for example 2 line edits with the name UI_Line0 and UI_Line1 you can do this:

    for(var i = 0; i < 2; i++)
    {
        eval("UI_Line" + i).setText("text" + i);
    }
    
     

    Last edit: Stefan Zieker 2024-01-19
  • devnull

    devnull - 2024-01-19

    Excellent! I knew eval from other languages, also there are more tricks in others for this. But in the end this works. Thank you mate!

     
  • Stefan Zieker

    Stefan Zieker - 2024-01-19

    np :-)

     
  • devnull

    devnull - 2024-01-19

    Just to have asked: Do you know an way to get all GUI elements programmatically? Maybe by their type?

     

Anonymous
Anonymous

Add attachments
Cancel