I am trying to create a horizontal slider button and bar, but have its max value change at run-time, depending on the value of a certain variable that may change.

In my game, I have it programmed so that if the player gets within a certain distance of a treasure chest or dead body, the player can press the "m" key, which will bring up the mouse cursor, and if the player clicks on the treasure chest or the dead body with the mouse cursor, both the player's inventory bag and the chest's inventory bag will show up on the screen, or the player's inventory bag and the dead body's inventory bag will show up on the screen, the idea being that the player can transfer item(s) to and from the treasure chest, or to and from a dead body.

If there are five swords in an inventory bag, only one image of a sword will display in the inventory bag, instead of five sword images. If you the player click on that one image of the sword, a set of information about that item will show up on the right side of the screen, showing how much of that item (sword quantity) is in that particular inventory bag.

If you the player want to transfer 3 swords to a treasure chest (even though you have 5 swords in your inventory), I want to make it so that if you the player drag the sword image from your inventory bag to the treasure chest's inventory bag, a message will come up asking you how many of that item you want to transfer, along with a horizontal slider bar, and a "Transfer" button. The horizontal slider bar's maximum value toward the far right should equal the maximum amount of swords that the player is capable of transferring at the present time (for example, 5 swords). The player can then slide the horizontal bar left or right, which decreases or increases the quantity of the item that she/he would like to transfer. Once the player leaves the horizontal slider button at a certain quantity value to transfer, and presses the "Transfer" button, the chosen quantity of that item to transfer (chosen by the horizontal slider button) should transfer to the treasure chest's inventory bag, and the remaining amount should go back to the player's inventory bag.

I am trying to use the hslider function to do this. However, I am confused as how to change the hslider's max value at run-time to equal the maximum amount of a particular item that the player is capable of transferring at a given time (for example, 5 swords). As of now, it only looks like the hslider's max value has to be hard-coded as a number (instead of a variable that can change) into the hslider's max value. I want the hslider's max value to equal the value of the variable that represents the maximum quantity of a particular item that the player is trying to transfer at a given time.

For example, I try to change the hslider's max value at run-time, by doing this:

Code:
hslider(450, 514, 150, "horizontalSlider.pcx", 0, item_quant_entFrom, transf_amt); // I get error from using
   //   the item_quant_entFrom variable.



...instead of this

Code:
hslider(450, 514, 150, "horizontalSlider.pcx", 0, 50, transf_amt); // I get no errors, but I am stuck with 50 as
   //    the hslider's maximum value that it can slide 
   //    toward the right to.



...but I get an error when I assign a variable to the max value, instead of hard coding it with an actual integer (like 50). However, I want this hslider max value to be dynamic, not static.

Here is what the code for my horizontal slider button and bar looks like so far:

Code:
...

TEXT* invTransferText =
{
	layer = 10;
	pos_x = 350;
	pos_y = 490;
	string ("HOW MUCH OF ITEM DO YOU WANT TO TRANSFER?: ");
}

PANEL* horizontalSliderBar =
{
	layer = 0;
	
	bmap = "horizSliderBar.pcx";
	pos_x = 440;
	pos_y = 508;
}

PANEL* invTransferAmount =
{
	layer = 1;
	
	hslider(450, 514, 150, "horizontalSlider.pcx", 0, 50, transf_amt);
	digits (590, 490, 5, *, 1, transf_amt);
	button(640, 510, "transfer_button_click.pcx", "transfer_button.pcx", "transfer_button_hover.pcx",
	       transferItems, NULL, NULL);
}

...



Does anyone know how to make the hslider max value dynamic, instead of static, so that it can change at run-time, depending on the value of a certain variable?