Archive: Troubles with config strings (APE)


30th September 2002 11:24 UTC

Troubles with config strings (APE)
I still have troubles saving strings in the config data and loading them.

WHEN are the 2 routine:

virtual void load_config(unsigned char *data, int len);
virtual int save_config(unsigned char *data);

called from AVS?

When a control is modified?
Do I have to call them?
Can I call them inside an APE?

Thx
Camillo


30th September 2002 18:35 UTC

whenever the ape is loaded (e.g. when someone loads an avs) the load_config one is called. it is also called say when you open the avs window after having closed while watching an avs containing your ape. basically it's called when you expect it to be...

save_config is called when someone either saves an avs or closes the avs window. again basically whenever it needs to be.

i don't think they're called every time a control is modified, this would seem like overkill, but it would be easy for you to check if it's really important just stick a MessageBox in the save routine.

you can also call them yourself, but you would only want to do this if you were giving your ape save and load buttons in which case you would pass the pointer to the block of data to be written/read from the file.

i've e-mailed you already with details of how to save strings.

tom


1st October 2002 13:49 UTC

I think only when a preset is saved and/or AVS is closed (and the current preset is saved).

I have any problems with saving/loading data, and in my latest APE I'm writing quite a lot (the colormapper). I hope you're not using the APE SDK's method of saving data though (i.e. byte per byte). I just use a struct 'apeconfig' which I write and read like this:

load:
memcpy(&this->config, data, sizeof(apeconfig));

save:
memcpy(data, &this->config, sizeof(apeconfig));
return sizeof(apeconfig);

You can even define multiple config structs later for backwards compatibility.


1st October 2002 14:48 UTC

using structs
BUT if you use a struct for in and out, you MUST set a max number of characters for string values.

Camillo


5th October 2002 02:11 UTC

Or use a struct for the fixed data and tack the strings on later. Like

int stringlen = len - sizeof(apeconfig);

I use this in my colormapper... I store 8 colormaps that can each have a variable length without a problem.