sinisrus wrote: ↑Thu Oct 14, 2021 4:45 pm
If i use CreateBrush(ID) With FOR => Good Work 1 brush maked
Code: Select all
FOR local i=1 TO 50 DO CreateBrush(1,200,200,#BLUE)
This will always create a brush with ID 1, so it replaces (and frees) the previous brush which had the same ID (1). Only one brush stays in memory.
If i use CreateBrush(NIL) With FOR => No good Work 50 brush maked
Code: Select all
FOR local i=1 TO 50 DO Test$=CreateBrush(NIL,200,200,#BLUE)
This will create new brushes with a different ID always ("Nil" produces an ID that isn't used before and guarantees that you don't accidently replace any prevous brush). You store the ID of each brush into the same variable (Test$) and after the loop the variable only contains the last ID. All 50 brushes are in memory, but you only know how to refer to the last brush, because you didn't store IDs of the first 49 brushes.
So yes, it's normal.
If you want to create 50 separate brushes and have their IDs stored, you could do like this:
Code: Select all
brush_ids = {}
FOR local i=1 TO 50 DO brush_ids[i]=CreateBrush(NIL,200,200,#BLUE)
Now you can refer to the first brush by brush_ids[1] and the last by brush_ids[50], and so on... to display brush 24 would be DisplayBrush(brush_ids[24], 0, 0)