allocation memore - SIZEOF structs

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by richard.

hi,

is there a sizeof in PB to use with structres???
is there a mod function?


thanx

richard
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by WooTz.

Hey,

Can't you calculate the size yourself? integer, long etc. are fixed length, and the string you can get with Len().

As for the mod:

while (numerator >= denominator)
numerator = numerator - denominator;

return numerator

thats just the pseudo code, go ahead and port it im still learning pure basic :)

Martin
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by richard.

hi,

sure one can count, but there are a lot of things missing in this basic. all those litte thing that make life nice and easier like - mod, shift ... and sizeof.

for example see gfa basic or the hla assembler http://webster.cs.ucr.edu/.

there are a lot of important things missing, like documentation,containers and other things.

richard
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by WooTz.

umm i dont believe there's a sizeof in QBasic or VB as well... and mod you could write on yourself OR use inline assembly in Pure Basic.....




Edited by - WooTz on 17 September 2001 20:40:46
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fred.
hi,

sure one can count, but there are a lot of things missing in this basic. all those litte thing that make life nice and easier like - mod, shift ... and sizeof.
Of course there is a SizeOf() function for structures.. Just try the following line:

MessageRequester("", Str(SizeOf(RECT)), 0)

And yes, shift are supported:

FastMulByTwo = Number > 2

It's like in C/C++.

BTW, the PureBasic compiler is smart enough to convert all mul & div by shift when it's possible..

So, only the mod stuff is missing :)



Fred - AlphaSND
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by WooTz.

I gave him the MOD =)

Logic dictates, that once you have eliminated the impossible, what ever remains, however improbable, must be the truth
Post Reply