Bennu can read clock data?

Started by Zip, June 01, 2011, 04:20:43 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Zip

Hi people today i want to make a binary clock!,
but i have a problem, can bennu read sys info linke Hours Minutes Sec? or date?
and another question, there is some binary translate func in bennu?

thanx ;)

handsource-dyko

There are some date and time functions in bennu. Mod_time has the ftime function, see http://wiki.bennugd.org/index.php?title=Mod_time for details. I don't know much about binary math operations since I never needed to work on bit level.


handsource-dyko

I see you made a typo. Change mod_timer into mod_timers. That should fix it.

Zip

import "mod_time"
import "mod_timers"
import "mod_text"
import "mod_key"

Process Main();
Private
    String timestring; // The string holding the formatted time
Begin

    write_string(0,0,0,0,&timestring); // Display the timestring
    timer = 100; // Make it so it updates the timestring immediately

    Repeat
    if(timer>100) // Update the timestring every 1 second
            timer = 0;
            timestring = ftime("%d-%m-%Y %H:%M:%S",time());
        end
        frame;
    Until(key(_esc))

End

other error:

Sandman

Looks like your editor replaced "timestring" with "×tring".
-- Sandman

BlackCurtain

Quote from: Sandman on June 04, 2011, 09:13:42 AM
Looks like your editor replaced "timestring" with "×tring".
I think that's an & sign which the code-highlight converted wrong.

Zip

what i need to do, for starting that example?

BlackCurtain

Try this instead
import "mod_time"
import "mod_timers"
import "mod_text"
import "mod_key"

Process Main();
Private
    String timestring; // The string holding the formatted time
Begin

    write_string(0,0,0,0,timestring); // Display the timestring
    timer = 100; // Make it so it updates the timestring immediately

    Repeat
    if(timer>100) // Update the timestring every 1 second
            timer = 0;
            timestring = ftime("%d-%m-%Y %H:%M:%S",time());
        end
        frame;
    Until(key(_esc))

End

I think the & sign in write() gave you the error

Zip

Quote:11: error: Data type not accepted here ( token error: "timestring" ).

BlackCurtain

use write() instead of write_string().

Zip

import "mod_time"
import "mod_timers"
import "mod_text"
import "mod_key"

Process Main();
Private
    String timestring; // The string holding the formatted time
timer;
Begin

    write(0,0,0,0,timestring); // Display the timestring
    timer = 100; // Make it so it updates the timestring immediately

    Repeat
    if(timer>100) // Update the timestring every 1 second
            timer = 0;
            timestring = ftime("%d-%m-%Y %H:%M:%S",time());
        end
        frame;
    Until(key(_esc))

End

in that version have'nt cmd error, but i see just a window all black

BlackCurtain

Quote from: Zip on June 06, 2011, 01:47:45 PM
import "mod_time"
import "mod_timers"
import "mod_text"
import "mod_key"

Process Main();
Private
    String timestring; // The string holding the formatted time
timer;
Begin

    write(0,0,0,0,timestring); // Display the timestring
    timer = 100; // Make it so it updates the timestring immediately

    Repeat
    if(timer>100) // Update the timestring every 1 second
            timer = 0;
            timestring = ftime("%d-%m-%Y %H:%M:%S",time());
        end
        frame;
    Until(key(_esc))

End

in that version have'nt cmd error, but i see just a window all black

Well you have to initialize the window first with set_mode()

Zip

no thats not the problem..
import "mod_time"
import "mod_timers"
import "mod_text"
import "mod_key"

process Main();
private
    String timestring; // The string holding the formatted time
timer;
begin
    set_mode(320,240,16);
    write(0,0,0,0,timestring); // Display the timestring
    timer = 100; // Make it so it updates the timestring immediately

    repeat
    if(timer>100) // Update the timestring every 1 second
            timer = 0;
            timestring = ftime("%d-%m-%Y %H:%M:%S",time());
        end
        frame;
    until(key(_esc))
let_me_alone();
end

its same.. black little window whitout string of text :/

Sandman

#14
write(0,0,0,0,timestring);
does not update, just writes the text as it is when you call it. You need
write_string(0,0,0,0,&timestring);

We can only conclude the compilation behaviour of Bennu has changed. The problem here is that Bennu handled references to arrays as though it were referencing the first elements. Thus timer was read as timer[0]. However, this version (don't know from which) does not do this. This means that it now gives a type error, because you try to compare an int[] and an int. So the solution is to use timer[0] instead of timer. Do not use your own private called timer, because that will not be updated by Bennu.

Correct code:
import "mod_time"
import "mod_timers"
import "mod_text"
import "mod_key"
import "mod_video"
import "mod_proc"

process Main();
private
   String timestring; // The string holding the formatted time
begin
   write_string(0,10,10,0,& timestring); // Display the timestring (the space after the & is not needed, just to fix the forum display...)
   timer[0] = 100; // Make it so it updates the timestring immediately

   repeat
    if(timer[0]>=100) // Update the timestring every 1 second
           timer[0] = 0;
           timestring = ftime("%d-%m-%Y %H:%M:%S",time());
       end
       frame;
   until(key(_esc))
let_me_alone();
end
-- Sandman