showing part of an array in digit

Posted By: Kitsu

showing part of an array in digit - 07/12/11 08:02

Hi,
i have a little problem with showing a part of an array in a digit.


while definination and declaration seems to work
Code:
STRING * res[6];
	res[0] = "640 x 480";
	res[1] = "800 x 600";
	res[2] = "1024 x 768";



but as i want to show it via
Code:
digits(0, 0, " %s", "Arial#16", 1, res[1]);

it shows only "(null)"

also unfortunately
Code:
str_cpy(resolution, res[num]);


gives me an malfunction says: "Empty pointer in set_res" (set_res is the function called by the button from the panel with the digits above)

what i have to do to use the part of the array in the digits and iin other functions without exactly know thwat the player wants and witout writing a new function for each possibility?
i hope you can help me with it smirk

greetings
~kitsu
Posted By: Rei_Ayanami

Re: showing part of an array in digit - 07/12/11 09:32

STRING * res[6]; //Ok
res[0] = "640 x 480"; //No
res[1] = "800 x 600"; //No
res[2] = "1024 x 768";//No

You need to make a function that inits the strings:

res[0] = str_create("640 x 480");
res[1] = str_create(..);
..
Then, the digits will work wink
Posted By: Kitsu

Re: showing part of an array in digit - 07/12/11 10:07

hmm anyhow the global declared string array isn't grey as the other global strings (and not shown in the code jumper on the right side)
also str_create isn't highlighted (?) and if i now call the function which shows the panel containing the digits the engine crashes (also it crahes instantly if the panel is shown at the beginning)
Posted By: MrGuest

Re: showing part of an array in digit - 07/12/11 11:46

Code:
///////////////////////////////
#include <acknex.h>
#include <default.c>

///////////////////////////////

FONT* fnt_test = "arial#20";
STRING* str_res[6];

PANEL* pnl_res = {
//	digits(10, 10, "%s", *, 1, str_res[0]); //wont' work, string is not yet initialised!
	flags = SHOW;
}

void main(){
	
	str_res[0]= str_create("600x480");
	str_res[1]= str_create("800x600");
	pan_setstring(pnl_res, 0, 10, 10, fnt_test, str_res[0]);
	pan_setstring(pnl_res, 0, 10, 30, fnt_test, str_res[1]);
}

though you'd be better off using TEXT instead of PANEL
Code:
TEXT* txt_res = {
	font = fnt_test;
	pos_x = 300;
	strings = 6;
	string("600x480", "800x600", "1024x768");
	flags = SHOW;
}


© 2024 lite-C Forums