2 registered members (AndrewAMD, TipmyPip),
13,353
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
getting some weird numbers out of it
#254071
02/28/09 21:44
02/28/09 21:44
|
Joined: May 2008
Posts: 13 Greece
ngiannakas
OP
Newbie
|
OP
Newbie
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
#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
Junior Member
|
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: 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! 
|
|
|
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
Ottawa
User
|
User
Joined: Apr 2006
Posts: 737
Ottawa, Canada
|
Hi! Here's what I use to debug my variables. It also works for other numbers.
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 
|
|
|
|