Converting from C to PB
-
- User
- Posts: 57
- Joined: Mon Dec 18, 2006 2:02 pm
- Location: Holland
Converting from C to PB
Anybody know how to convert this to PB:
struct something
{
uint8 year[5][5]
}
?
struct something
{
uint8 year[5][5]
}
?
-
- Addict
- Posts: 1073
- Joined: Fri Apr 25, 2003 11:13 pm
- Location: Netherlands
- Contact:
-
- User
- Posts: 57
- Joined: Mon Dec 18, 2006 2:02 pm
- Location: Holland
-
- User
- Posts: 57
- Joined: Mon Dec 18, 2006 2:02 pm
- Location: Holland
Use:Philippe-felixer76 wrote:Why isn't it possible to use dim foo.l(5,5) in a structure..
Code: Select all
Structure foo
bar.l[5]
EndStructure
Windows 7 & PureBasic 4.4
Multidimensional arrays in structures aren't supported (by now).Philippe-felixer76 wrote:Why isn't it possible to use dim foo.l(5,5) in a structure..
You could however work around this limitation something like this:
Code: Select all
Structure something_
a.c[5]
EndStructure
Structure something
b.something_[5]
EndStructure
Good programmers don't comment their code. It was hard to write, should be hard to read.
-
- User
- Posts: 57
- Joined: Mon Dec 18, 2006 2:02 pm
- Location: Holland
This is interesting, i was thinking this way also, using a substructure...traumatic wrote:Multidimensional arrays in structures aren't supported (by now).Philippe-felixer76 wrote:Why isn't it possible to use dim foo.l(5,5) in a structure..
You could however work around this limitation something like this:Yes, ugly, I know...Code: Select all
Structure something_ a.c[5] EndStructure Structure something b.something_[5] EndStructure
You say 'By now', can't some of the core devels
tell/post something about this? Something about
support planned in very near future?
- Kaeru Gaman
- Addict
- Posts: 4826
- Joined: Sun Mar 19, 2006 1:57 pm
- Location: Germany
why not use a linear array in the struct and calculate line and row, e.g. by a Macro?
Code: Select all
Macro BiCoord5( BCRow, BCLine )
( 5 * BCLine + BCRow )
EndMacro
Structure Puit
Narf.c[25]
EndStructure
Define Fjord.Puit
Fjord\Narf[BiCoord5(2,3)] = 42
Debug Fjord\Narf[BiCoord5(2,3)]
oh... and have a nice day.
-
- User
- Posts: 57
- Joined: Mon Dec 18, 2006 2:02 pm
- Location: Holland
YES, Great solution! Tnx!Kaeru Gaman wrote:why not use a linear array in the struct and calculate line and row, e.g. by a Macro?
Code: Select all
Macro BiCoord5( BCRow, BCLine ) ( 5 * BCLine + BCRow ) EndMacro Structure Puit Narf.c[25] EndStructure Define Fjord.Puit Fjord\Narf[BiCoord5(2,3)] = 42 Debug Fjord\Narf[BiCoord5(2,3)]
- Psychophanta
- Always Here
- Posts: 5153
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Anare
- Contact:
-
- User
- Posts: 57
- Joined: Mon Dec 18, 2006 2:02 pm
- Location: Holland
:P
Psychophanta wrote:http://www.purebasic.fr/english/viewtopic.php?t=15752
:roll:

- Psychophanta
- Always Here
- Posts: 5153
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Anare
- Contact:
Re: :P
Not really, i just saw it is useful.Philippe-felixer76 wrote:Was your motivation also to get porting from C to PB easyer?
-
- User
- Posts: 57
- Joined: Mon Dec 18, 2006 2:02 pm
- Location: Holland
Re: :P
Thats a fact!Psychophanta wrote:Not really, i just saw it is useful.Philippe-felixer76 wrote:Was your motivation also to get porting from C to PB easyer?

It also makes porting C headers a lot easy'er,
and makes adding purebasic user libs easy'er,
and makes purebasic more and more powerfull,
and makes all purebasic users and developpers very happy.
and makes purebasic a more complete product,
and makes the world a better place!