type and field question
Blitz3D Forums/Blitz3D Beginners Area/type and field question
| ||
hi, i want to make something like this, can i?type race field laps field cars field positiones[laps,cars] <--- ??? blitz say error :) field time_lap[laps,cars] end type i want to record the position of all cars in each lap of the race.. |
| ||
Blitz arrays cannot be multi-dimensional. |
| ||
:( in a type neither i can't use field positiones ( cars, laps ) ? |
| ||
hi you are using blitz arrays (declraded with [] ) and as the help says: "They cannot be multi-dimensional, and cannot be resized." the error is for that, i think. try type lap field number field positiones[cars] <--- ??? blitz say error :) field time_lap[cars] end type and do a list of lap's (with the lap number and time for each car and position for each car) Should work or: laps.lap[NumberOfLaps] an array of type lap with NumberOfLaps elements Juan |
| ||
yes, instead use: positiones( cars * max_number_of_laps + laps ) or positiones( laps * max_number_of_cars + cars ) |
| ||
:) thanks! |
| ||
You _can_ have arrays within arrays, eg:Type Jseq Field name$ Field startframe Field endframe End Type Const nMaxCharSeqs = 10 Type JChar Field label$ Field seq.Jseq[nMaxCharSeqs] End Type Global nNumChars = 10 Dim char.JChar(nNumChars) For z = 0 To nNumChars char(z) = New JChar For cnt = 0 To nMaxCharSeqs char(z)\seq.Jseq[cnt] = New Jseq Next Next ; accessed through: ; char(num)\seq[z]\name$ |
| ||
Not sure if it's better/worse or anything, but couldnt the positions/laps be stored with a separate type?type lap field lap_number field time field positon end type type race field car field laps.lap end type |
| ||
Yes, but again, see my definition above and adapt it to your own needs. |