Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
4 registered members (NewbieZorro, Grant, TipmyPip, AndrewAMD), 13,346 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
getting some weird numbers out of it #254071
02/28/09 21:44
02/28/09 21:44
Joined: May 2008
Posts: 13
Greece
N
ngiannakas Offline OP
Newbie
ngiannakas  Offline OP
Newbie
N

Joined: May 2008
Posts: 13
Greece
for some reason the calculations I try to perform are getting wrong results, if anyone sees anything I don't please tell me

usual output count being minus several thousands to plus several thousands, but never starting at 0 as it should, after start it keeps counting the number it output correctly

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

double start_time = 0;
double passed_time = 0;

STRING* debug_string1 = "";
STRING* debug_string2 = "";
STRING* debug_string3 = "";

FONT* debug_font = "Arial#20b";

TEXT* debug_text =
{
	pos_x = 0;
	pos_y = 0;
	string(debug_string1, debug_string2, debug_string3);
	font = debug_font;
	flags = VISIBLE;
}

function main()
{
	level_load(NULL);
	
        //start of program as date in seconds
	start_time = (sys_year - 1) * 365;
	start_time = (start_time + sys_doy - 1) * 24;
	start_time = (start_time + sys_hours) * 60;
	start_time = (start_time + sys_minutes) * 60;
	start_time = start_time + sys_seconds;

	//some debug info
	str_for_float(debug_string1, start_time);
	str_cat(debug_string1, " ");
	str_cat(debug_string1, str_for_int(NULL, sys_year));
	str_cat(debug_string1, "/");
	str_cat(debug_string1, str_for_int(NULL, sys_doy));
	str_cat(debug_string1, " ");
	str_cat(debug_string1, str_for_int(NULL, sys_hours));
	str_cat(debug_string1, ":");
	str_cat(debug_string1, str_for_int(NULL, sys_minutes));
	str_cat(debug_string1, ":");
	str_cat(debug_string1, str_for_int(NULL, sys_seconds));
	
	while(1)
	{
                //current date in seconds
		passed_time = (sys_year - 1) * 365;
		passed_time = (passed_time + sys_doy - 1) * 24;
		passed_time = (passed_time + sys_hours) * 60;
		passed_time = (passed_time + sys_minutes) * 60;
		passed_time = passed_time + sys_seconds;


		//some more debug info
		str_for_float(debug_string2, passed_time);
		str_cat(debug_string2, " ");
		str_cat(debug_string2, str_for_int(NULL, sys_year));
		str_cat(debug_string2, "/");
		str_cat(debug_string2, str_for_int(NULL, sys_doy));
		str_cat(debug_string2, " ");
		str_cat(debug_string2, str_for_int(NULL, sys_hours));
		str_cat(debug_string2, ":");
		str_cat(debug_string2, str_for_int(NULL, sys_minutes));
		str_cat(debug_string2, ":");
		str_cat(debug_string2, str_for_int(NULL, sys_seconds));
		
		str_for_float(debug_string3, (passed_time - start_time));
		wait(-0.1);
	}
}


also why does panel editor crash?

Re: getting some weird numbers out of it [Re: ngiannakas] #254136
03/01/09 11:57
03/01/09 11:57
Joined: Feb 2009
Posts: 84
Deutschland/Niedersachsen
GorNaKosh Offline
Junior Member
GorNaKosh  Offline
Junior Member

Joined: Feb 2009
Posts: 84
Deutschland/Niedersachsen
I had only a quick look at your stuff, and found this problem:
You should initialize the strings correctly. You have three empty string-pointer with the length of zero, so you can't store any chars in this strings. (Take a look at the manual)

This are ways to initialize strings:
Code:
STRING* debug_string1 = "#99"; //length of 99 chars
STRING* debug_string2;
STRING* debug_string3;

void init_str_startup() {
debug_string2 = str_create("#99");
debug_string3 = str_create("This would be correct!");
}


Hope this helps! wink

Re: getting some weird numbers out of it [Re: GorNaKosh] #254170
03/01/09 15:16
03/01/09 15:16
Joined: May 2008
Posts: 13
Greece
N
ngiannakas Offline OP
Newbie
ngiannakas  Offline OP
Newbie
N

Joined: May 2008
Posts: 13
Greece
strings work as they were, was getting output, but found the problem anyways

seems the engine needs two frames at least to get system info, adding wait(2); before getting the first set of variables made it work (added a whole second to be sure)

but still panel editor plug in crashes if adding any element on it

Re: getting some weird numbers out of it [Re: ngiannakas] #254252
03/02/09 00:48
03/02/09 00:48
Joined: Apr 2006
Posts: 737
Ottawa, Canada
O
Ottawa Offline
User
Ottawa  Offline
User
O

Joined: Apr 2006
Posts: 737
Ottawa, Canada
Hi!

Here's what I use to debug my variables.
It also works for other numbers.
Code:
PANEL* debug = {
	pos_x = 400;
	pos_y = 50;
	layer = 3;
	digits (0,0,"_le_tour_de: %f ",*,1, _le_tour_de1);//
	digits (0,20,"rendu: %f ",*,1, rendu);//
	digits (0,35,"renduhaut: %f ", *,1,renduhaut);
	digits (0,45,"desc_bas: %f ", *,1,desc_bas);
	digits (0,65,"combien: %f ", *,1,compte_combien);
	digits (0,85,"qui: %f ", *,1,_Tpos_x); //qui
	digits (0,105,"_valeur1ou2: %f ", *,1,_valeur1ou2);
	flags =  OVERLAY  ;// |;// | SHOW for 7.7 visible VER before that
}

Ottawa smile


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1