PDA

View Full Version : Code porting from C


Gerben
10-29-2006, 10:28 AM
Good morning,

I am trying to port some code from C to PPL. Trying to create a structure with multi-dimensional array. Have checked the help and tutorials but I am not getting it.....

Below is the C code.

typedef struct {
unsigned long P[16 + 2];
unsigned long S[4][256];
} BF_CTX;

BF_CTX ctx;

How do I get this in PPL, please? I would like to have ctx global. Thanks

kornalius
10-29-2006, 02:20 PM
Having CTX won't be a problem. However I have deactivated arrays in structures by mistake in 1.06. It used to work fine before. I will put it back in 1.07 this week.

This declaration would look like this in PPL:

globa(ctx$); // Make ctx$ global to all application.
struct(ctx$, "p", "s"); // Define structure elements (as double types)
dim(ctx.p$, 18); // [16 + 2]
dim(ctx.s$, 4, 256); // [4][256]

PPL uses Double (8 bytes) by default. If you really need unsigned long, try the following:

globa(ctx$); // Make ctx$ global to all application.
struct(ctx$, "p", "s"); // Define structure elements (as unsigned int)
tdim(ctx.p$, tuint, 18); // [16 + 2]
tdim(ctx.s$, tuint, 4, 256); // [4][256]

Don't worry you should be able to use this code in a couple days (Tuesday most probably).

Gerben
10-29-2006, 06:46 PM
Thanks again for the quick and clear reply.

I need to get used to declaring sort of step-by-step. (Global, then struct etc.). This example makes it all clearer.

I am in no hurry so I have no problems with waiting for 1.07 to give this code a go.

Greetings, Gerben