Passing strings to a type
BlitzMax Forums/BlitzMax Beginners Area/Passing strings to a type
| ||
I have and another one newbie question. How to pass a string in a type. For example Type My_Type field the_string:string Endtype The_type:My_Type If I will try to use The_type.the_string="Blah" The program crashes. Any idea? :o) |
| ||
You need to use new before using the type The_type:My_Type = new My_Type |
| ||
Another common approach is using: Type XY Function Create:XY(params) local obj:XY = new obj obj.param1 = param1 return obj End Function End Type Global The_Type:XY = XY.Create(params) bye Ron |
| ||
And if my type is an array?Type My_Type field the_string:string Endtype The_type:My_Type[100] The_type:My_Type= new My_Type[100] drops error I tried all kinds of The_type:My_Type[100] = new My_Type The_type:My_Type[100] = new My_Type[100] Or The_type[100]:My_Type = new My_Type ???? |
| ||
And if my type is an array? Each element in the array needs to 'New'd indiviually. Global Array:My_Type[100] For Local i = 0 until 100 Array[i] = New My_Type Next |
| ||
Each element in the array needs to 'New'd indiviually. Global Array:My_Type[100] For Local i = 0 until 100 Array[i] = New My_Type Next At last it worked. THANK YOU VERY VERY MUCH. My game now went one step farther. There is not any in depth manual to explain these. |