From what I am understanding, by the looks of part of your code such as
Code:
Slot* new_slot;
new_slot = new(Slot);


you are trying to use structs. You cannot (as far as I am aware) store variables in functions. Functions are just routines or methods that allow you to modify data, call other routines, etc. You can do as the others were saying and save these variables to global variables so that you can always access them, However the downside to that is if you decide to make more inventory slots, you must go add more global variables to match the new slots.

Back to using stucts. Structs are the best way to go in this situation because for every new "slot" you want to add, create a new "instance" of a slot struct and now you can easily access those variables per instance. example
Code:
typedef struct{
var rel_x_pos, rel_y_pos;
STRING* background_image;
var item;
var id;
var group_id;
var bag_id;
} Slot;

If you have already done that, sorry for typing code.
Once that is done, if you have stored the instances in an array example.
Code:
Slot* inv_slots[100];
inv_slots[0] = new Slot;


you could easily access the variables like this
Code:
inv_slots[21].item = 2; // or what ever you want to do with it.
//or change the background picture like this.
inv_slots[53].background_image = "newBackground.pcx";


I hope this helps. If not I sincerely apologize.
Best wishes!