Login
Username:

Password:

Remember me



Lost Password?

Register now!
Sections
Who's Online
82 user(s) are online (61 user(s) are browsing Forums)

Members: 2
Guests: 80

duga, emeck, more...
Support us!
Recent OS4 Files
OS4Depot.net
Report message:*
 

Re: Do we have an execpl replacement?

Subject: Re: Do we have an execpl replacement?
by AmigaBlitter on 2018/2/22 15:45:09

Found this code on Amiga Wiki page, but seems not working or not updated

/* Get_Systime.c
 *
 * Get system time example
 *
 * Run from CLI only
 */
 
#include <exec/types.h>
#include <exec/io.h>
#include <exec/memory.h>
#include <devices/timer.h>
 
#include <proto/exec.h>
#include <proto/dos.h>
 
 
int main(void)
{
  
int32 error;
  
uint32 days,hrs,secs,mins,mics;
 
  
struct MsgPort *TimerMP IExec->AllocSysObjectTags(ASOT_PORTTAG_END);
 
  if (
TimerMP != NULL)
  {
    
struct TimeRequest *TimerIO IExec->AllocSysObjectTags(ASOT_IOREQUEST,
      
ASOIOR_Sizesizeof(struct TimeRequest),
      
ASOIOR_ReplyPortTimerMP,
      
TAG_END);
 
    if (
TimerIO != NULL)
    {
        
/* Open with UNIT_VBLANK, but any unit can be used */
        
if (!(error IExec->OpenDevice(TIMERNAME,UNIT_VBLANK,(struct IORequest *)TimerIO,0L)))
        {
            
/* Issue the command and wait for it to finish, then get the reply */
            
TimerIO->tr_node.io_Command TR_GETSYSTIME;
            
IExec->DoIO((struct IORequest *) TimerIO);
 
            
/* Get the results and close the timer device */
            
mics TimerIO->tr_time.tv_micro;
            
secs TimerIO->tr_time.tv_secs;
 
            
/* Compute days, hours, etc. */
            
mins secs 60;
            
hrs  mins 60;
            
days hrs 24;
            
secs secs 60;
            
mins mins 60;
            
hrs  hrs 24;
 
            
/* Display the time */
            
IDOS->Printf("nSystem Time (measured from Jan.1,1978)n");
            
IDOS->Printf("  Days   Hours  Minutes Seconds Microsecondsn");
            
IDOS->Printf("%6ld %6ld %6ld %6ld %10ldn"dayshrsminssecsmics);
 
            
/* Close the timer device */
            
IExec->CloseDevice((struct IORequest *) TimerIO);
        }
        else
            
IDOS->Printf("nError: Could not open timer devicen");
 
        
/* Delete the IORequest structure */
        
IExec->FreeSysObject(ASOT_IOREQUESTTimerIO);
    }
    else
        
IDOS->Printf("nError: Could not create I/O structuren");
 
    
/* Delete the port */
    
IExec->FreeSysObject(ASOT_PORTTimerMP);
  }
  else
    
IDOS->Printf("nError: Could not create portn");
 
  return 
0;
}



Gettime.c: In function 'main':
Gettime.c:39: error: 'struct TimeRequest' has no member named 'tr_node'
Gettime.c:43: error: 'struct TimeRequest' has no member named 'tr_time'
Gettime.c:44: error: 'struct TimeRequest' has no member named 'tr_time'
Gettime.c:78:2: warning: no newline at end of file

@xenic

Thank you for the info
Powered by XOOPS 2.0 © 2001-2016 The XOOPS Project