[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference hydra::amiga_v1

Title:AMIGA NOTES
Notice:Join us in the *NEW* conference - HYDRA::AMIGA_V2
Moderator:HYDRA::MOORE
Created:Sat Apr 26 1986
Last Modified:Wed Feb 05 1992
Last Successful Update:Fri Jun 06 1997
Number of topics:5378
Total number of notes:38326

2681.0. "DateStamp function problem!!!" by EEMELI::LINDEN () Mon Jun 26 1989 08:36

    Hi, I need help using DateStamp function (dos.h).
    I'm trying to create procedure TIMER that reads time info from
    DateStamp, but so far I haven't succeeded.
    
    The procedure is done in MCC Pascal that can use AmigaLibraries just
    like in C, but I haven't got too much knowledge about C so ...
    it hasn't worked so far.
    
    I preciate any help that you can give me about how use DateStamp.
    
    - Kari.
    
T.RTitleUserPersonal
Name
DateLines
2681.1DateStamp( v );EEMELI::LINDENTue Jul 11 1989 09:537
    Well sofar I haven't got the DateStamp( v ) working, but I have found
    two source codes for Clock programs wich uses DateStamp( v ) function, 
    but because I don't have knowledge of C I wanna know what does '&'
    standfor in an function call before an variable ie. DateStamp( &now );
    
    - Kari
    
2681.2TALLIS::MCAFEESteve McAfeeTue Jul 11 1989 11:5718
    
    & means supply the address of the variable.  so if you have
    
    	int num;
    
    	incr( &num);
    
    then incr might do something like:
    
    	void incr ( val)
    	int *val;
    	{
    	*val += 1;
    	}
    
    Notice that this actually increments the value in num.
    
    - steve
2681.3EEMELI::LINDENTue Jul 11 1989 12:215
    Thanks !!
    
    Now I've an change getting the DateStamp(v) work in the MCC Pascal.
                                                        
    -Kari
2681.4Sample program using DateStamp...EEMELI::LINDENWed Jul 12 1989 13:2549
    Nope, I didn't get it work... I getting quite desperate with this
    program....
    
    Well here is my Pascal listing for it:
    
    ---
    PROGRAM date(input,output);
    
    INCLUDE 'libraries/dos.h';
    INLCUDE 'libraries/dosextens.h';
    
    VAR
    	now : Datestamp;
    	hours, minutes : REAL;
    
    INCLUDE 'libraries/dos';
    
    BEGIN
    	DateStamp ( now );  <--- here compiler tells SYNTAX ERROR ....
    	hours := now.ds_Minute / 60;
    	minute := now.ds_Minute MOD 60;
    	WRITELN ( hours, minutes, now.ds_Tick / TICKS_PER_SECOND );
    END.
    ---
    
    And the MCC Pascal has declared the DateStamp and it's variables :
    
    In 'libraries/dos.h':
    
        ---
    	TYPE
    		DatestampPtrType �Datestamp;
    
    		Datestamp =
    			PACKED RECORD
    			 ds_Days, ds_Minute, ds_Tick : INTEGER;
    			END;
         ---
    
    and in 'libraries/dos':
    
        ---
    	FUNCTION DateStamp(v:DatestampPtrType) : DatestampPtrType; EXTERNAL;
        ---
    
    So I'm still stuck on the same problem as in the first note.
    
    - Kari
    
2681.5TALLIS::MCAFEESteve McAfeeWed Jul 12 1989 14:1118
    I believe the problem is that you declared:
    
    now : Datestamp;
    
    I thing what you want is:
    
    now : DatestampPtrType; 
    
    This is because the argument to the function must be a pointer to the
    Datestamp record.  Pascal/M2 are strongly typed and will give you errors
    when you supply the wrong type of argument.  You will probably want to do a
    new( now);  before you call Datestamp.  This will allocate the space
    for the record.  Also somewhere before you exit you should do a
    dispose( now); to free up this memory.
    
    regards,
    
    steve
2681.6I'll try it again...EEMELI::LINDENThu Jul 13 1989 10:228
    I think that I've already tried that, but I'll check it out !
    This problem has bugged me almost three weeks for now...so I'm getting
    quite desperate..8+) Well maybe it just feels too hard to overcome...
    
    Anyway thanks again for the help!!!
    
    - Kari
     
2681.7IT WORKS AFTERALL!!!EEMELI::LINDENFri Jul 14 1989 10:4545
    The big fight against the DateStamp problem is over and I did solve the 
    problem wich I had in it.
    
    Thank You very much Steve for the last help you gave me, it helped lot,
    although it wasn't the straight answer.
    
    Here the final working Pascal listing for the problem, hopefully it is
    usefull if someone else is having problems with system function on
    the MCC Pascal.
    
    This ain't the cleanest code that I can generate because this is just
    an test to get DateStamp workable and the final version will used in
    port of an PC Benchmark program written in Turbo Pascal, that should be
    ready for this weekend, so I might then reveal some benchmark test
    results with AMY at 7 and 14 Mhz speeds against some PC's.
    
    ---
    PROGRAM time(output);
    
    INCLUDE 'libraries/dos.h';
    INCLUDE 'libraries/dosextens.h';
    
    VAR
    	now : DatestampPtrType;
    	hours, minutes : REAL;
    	h, m : INTEGER;
    
    INCLUDE 'libraries/dos';
    
    BEGIN
    
    	NEW ( now ); (* make space available to the pointer *)
    	now := DateStamp ( now ); (* read time to pointer *)
    	hours := now�.ds_Minute / 60; (* calculate hours *)
    	minutes := now�.ds_Minute MOD 60; (* calculate minutes *)
    	h := TRUNC ( hours ); (* make hours as integer *)
    	m := TRUNC ( minutes ); (* make minutes as integer *)
    	WRITELN ( 'Time is : ',h:2,' : ',m:2,' : ',now�ds_Tick / TICKS_PER_
    		SECOND:5:2 );
    	DISPOSE ( now ); (* free the memory for pointer *)
    
    END.
    ---
    
    - Kari