Custom Type using as array
BlitzMax Forums/BlitzMax Beginners Area/Custom Type using as array
| ||
Hello everybody, I'm new to BMax and about to convert my old projects to BMax syntax. In the moment I'm stucking with my old BBTypes that cannot be converted properly with "BB Import". I've set up my own type Type fld Field type,name$ End Type and need to use it as an array: Local f[fldnum] 'fldnum is something between 1 to 100 For x=0To fldnum 'here's my problem: I want to save data from a file to my custom type, but doesn't work :( f[x]:typ=ReadByte(file) f[x]:name=ReadString(file) Next The compiler reports: "Expecting expression but encountered ':'" Any suggestion how to dow it the right way? I don't have the Max-logic yet. Many thanks in advance Simon Uups: Wrong forum, please move! |
| ||
Change it like this- Local f:fld[fldnum] f[x].typ=ReadByte(file) |
| ||
Also note that arrays are zero indexed in BMax, so...Local f:fld[fldnum] For x = 0 Until fldnum ' could use (0 To fldnum - 1) too f[x].typ = ReadByte(file) f[x].name = ReadString(file) Next [edit] Just noticed...Isn't this in the wrong forum? [/edit] |
| ||
Uups: Wrong forum, please move! He figured it out :P |
| ||
The code is now working. I had to add f[x]=New fld as well. I'm still struggeling a bit with the new BMax syntax. I used Blitz for many years, but now that I'm on university I don't have a lot of spare time to work focused with BMax. @Yan: I was looking for a similar threat before posting and missed to change to the right forum. Sorry. |
| ||
No need to apologise to me, I pointed it out for the moderators benefit more than anything. I didn't see the comment in your original post. I should be the one apologising for failing to initialise the type...Doh! |