Digits Probs :X

Posted By: Yashas

Digits Probs :X - 12/01/12 16:10

Code:
typedef struct UserProfile
	{
		STRING * Name;
		STRING * Password;
		
		STRING * EMail;
		Date DOB;
		Date DOC;
		
		int BPI;
		int XP;
		
		int RegionSpeed;
		int RegionMemory;
		int RegionAttentition;
		int RegionFlexibility; 
		int RegionLogic;
		
		int Rank;
		int BestRegion;
		int TexPoints;
		int MostCommonRegion;
		int BestRegion;
		
		int SelectedRegion;
	}UserProfile;


Code:
PANEL * V10StatsDialog =
{
	event = MoveWindow;
	button(580,6,XButtonClicked,XButtonNormal,XButtonNormal,FormXButtonClicked,NULL,NULL);
	digits(5,5,"My Stats",DialogTitle,1,0);
	digits(10,40,"BrainPerformanceIndex:%d",DialogSubText,1,ActiveProfile.BPI);
	digits(10,100,"Speed:%d",DialogSubText,1,ActiveProfile.RegionSpeed);
	digits(10,140,"Memory:%d",DialogSubText,1,ActiveProfile.RegionMemory);
	digits(10,180,"Flexibility:%d",DialogSubText,1,ActiveProfile.RegionFlexibility);
	digits(10,220,"Problem Solving:%d",DialogSubText,1,ActiveProfile.RegionLogic);
	digits(10,260,"Attentition:%d",DialogSubText,1,ActiveProfile.RegionAttentition);
	
	digits(10,360,"Rank:%d",DialogSubText,1,ActiveProfile.Rank);
	digits(10,400,"XP:%d",DialogSubText,1,ActiveProfile.XP);
	

	digits(10,460,"Rank 1:",DialogSubText,1,0);
	digits(10,500,"Rank 2:",DialogSubText,1,0);
	digits(10,540,"Rank 3:",DialogSubText,1,0);
	
	digits(110,460,"%s",DialogSubText,1,0);
	digits(110,500,"%s",DialogSubText,1,0);
	digits(110,540,"%s",DialogSubText,1,0);
	
	
	
	alpha = 0;
	bmap = DialogBackground;
	layer = 5;
	flags = TRANSLUCENT;
}



If ActiveProfile.BPI is 20 I get the digits in the PANEL showing 0!
Wats wrong here???

Thanks
Posted By: Kartoffel

Re: Digits Probs :X - 12/01/12 17:40

the digits element doesn't support integers.

There's a workaround but I'm not sure if this really isn't causing trouble to the rest of the code:
Code:
digits(10,40,"BrainPerformanceIndex:%f",DialogSubText,1024,ActiveProfile.BPI);



EDIT: since you're using an integer use %.0f in the format string to cut off the .00000
Posted By: Uhrwerk

Re: Digits Probs :X - 12/01/12 17:43

The correct format pattern for integers is %d, not %f!

http://www.cplusplus.com/reference/cstdio/printf/
Posted By: Kartoffel

Re: Digits Probs :X - 12/01/12 17:45

I know but this doesn't work for digits...
(I think it only supports %s and %f)
Posted By: Ch40zzC0d3r

Re: Digits Probs :X - 12/01/12 19:04

Who the hell uses digits?
Use str_printf and draw_text..
Posted By: WretchedSid

Re: Digits Probs :X - 12/01/12 19:24

Who the hell writes shitty "answers" like yours?
Posted By: Wjbender

Re: Digits Probs :X - 12/01/12 19:55

Also note that %i means integer in c++ but i dont know if
gs supports it you could try "%d",(long)value or "%d",(int)value or "%d",integer(value)
and i dont know if this is relevant but you could printf the value into the text
and use the text in the digit field perhaps if printf supports more formatting
Posted By: Kartoffel

Re: Digits Probs :X - 12/01/12 20:04

tested it, gs supports neither %d nor %i.
combining the var parameter with a cast operator results in a compiling error ('[..] too many parameters [..]')

(edit: we're still talking about the digits-element, right?)
Posted By: Yashas

Re: Digits Probs :X - 12/02/12 04:28

Code:
digits(10,40,"BrainPerformanceIndex:%0.f",DialogSubText,1,ActiveProfile.BPI);


shows a zero always even though the BPI value is something else.

When I remove Active...BPI parameter and install any integer ,it works!!
Code:
digits(10,40,"BrainPerformanceIndex:%0.f",DialogSubText,1,34);



Why is not ActiveProfile.BPI not working??
Posted By: Yashas

Re: Digits Probs :X - 12/02/12 04:34

^^When I set ActiveProfile.BPI to 443000 it shows 433 smirk
Posted By: Wjbender

Re: Digits Probs :X - 12/02/12 05:07

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

int xx=20;//<-your int value inside structure

var yy;//<-temp var that will be displayed inside panel

PANEL* my_panel =
{
	pos_x = 100;
	pos_y = 50;

	digits(0,0,"%.0f",*,1,yy);//<-- seems to only take a variable 
	 
 	flags = SHOW | OUTLINE;
}

function main()
{
  vec_set(screen_size,vector(800,400,0));
  vec_set(screen_color,vector(50,1,1)); // dark blue
  vec_set(sky_color,vector(50,1,1)); // dark blue
  video_window(NULL,NULL,0,"My New Game");
  d3d_antialias = 1;
  shadow_stencil = 3;
  
  level_load("");
  vec_set(camera.x,vector(-250,0,50));
  vec_set(camera.pan,vector(0,-15,0));

	while(1)
	{
		xx+=1;
 		yy=(int)xx;//<-converted into var just for displaying purpose
 					  //but xx is stil int value 
 		wait(1);
	}

}



Only global var variables or global predefined STRING* pointers
can be displayed (no int, float, char, or other types of variables).
The var can be part of a global struct or of an array, but not of a multidimensional array.
Posted By: Yashas

Re: Digits Probs :X - 12/02/12 05:10

Thanks FIXED!!
Just changed all the data-types in my struct to vars and it works laugh
Posted By: Kartoffel

Re: Digits Probs :X - 12/02/12 08:30

What about the workaround I posted?
( digits(20, 20, "%.0f",* ,1024, an_integer); )

I just want to know if this is completely wrong and will cause anything to crash.
an integer has the same size as a float / var so there shouldn't be a memory problem confused
and the *1024 compensates the number difference perfectly...
© 2024 lite-C Forums