Dernières versions
...
Menu  Langue: en
Recherche




Articles & Documents

Fermer Tutoriaux

Préférences

Se reconnecter
---

Votre nom (ou pseudo) :

Votre code secret


 Nombre de membres 421 membres


Connectés :

( personne )
CPDB.Net

Nouvelles des Amis
Pub Google
Lettre d'information
Pour avoir des nouvelles de ce site, inscrivez-vous à notre Newsletter.
S'abonner
Se désabonner
24 Abonnés
Webmaster - Infos
Visites

   visiteurs

   visiteurs en ligne

Pagerank
forum.gifForum - ppCompiler [EN] - Sujet n°27

Forum - Forum
ppCompiler [EN] - ppCompiler [EN]


actif  Sujet n° 27  Procedure TimSecondsToDateTime

le 19/09/2010 @ 15:23
par dearjohn

Anonyme



I can not handle this procedure, in my opinion the following should work to get the month, but the last line "m:=MyDateTime.month;" fails compiling with error: unexpected "." What's wrong with it, MyDateTime is of type DateTimePtr?

Const
SYSTRAP = $4E4F;
sysTrapTimSecondsToDateTime = $A0FC;

Type
UInt8  = -128..127;
Uint16 = 0..65535;
UInt32 = integer;

  DateTimeType = record
    second: UInt16;
    minute: UInt16;
    hour: UInt16;
    day: UInt16;
    month: UInt16;
    year: UInt16;
    weekDay: UInt16; // Days since Sunday (0 to 6)
  end;

  DateTimePtr = ^DateTimeType;

var
MyDateTime : DateTimePtr;
m          : integer;

(* ===== TIME =====*)
function  TimGetSeconds:UInt32; inline(SYSTRAP,$A0F5);
function  TimGetTicks:UInt32; inline(SYSTRAP,$A0F7);
procedure TimSecondsToDateTime(seconds: UInt32; dateTimeP: DateTimePtr);
inline(SYSTRAP, sysTrapTimSecondsToDateTime);

begin
TimSecondsToDateTime(TimGetSeconds,MyDateTime);
m:=MyDateTime.month;
end.

 

Thanks in advance. Reinhard.

Ecrire à dearjohn   Poster une réponse  Haut
Réponse n° 1
--------
le 23/09/2010 @ 17:44
par Philippe

Anonyme


The error is because you try to access to a field for a non record type. The "MyDateTime" is a pointer, not a record.
To fix the problem in the spirit of Pascal Language, you should define :

procedure TimSecondsToDateTime(seconds: UInt32; var dateTimeP: DateTimePtr);
inline(SYSTRAP, sysTrapTimSecondsToDateTime); // with the secont parameter passed by reference with the keyword var

Then the "MaDateTime" should be declared as a DateTimeType, not a pointer:
var MyDateTime : DateTimeType;

And then all should go fine.

If you prefer keep the "MyDateTime" variable as a pointer, it must be allocated before being used, with

new(MyDateTime);

And then, access to the "month" field is done by

m:=MyDateTime^.month;

Philippe.
Ecrire à Philippe   Poster une réponse  Haut
Réponse n° 2
--------
le 23/09/2010 @ 18:26
par Philippe

Anonyme


There remainds an error in the definition of TimSecondToDateTime in my previous message. With the keyword var, the second parameter is of type DataTimeType.

procedure TimSecondsToDateTime(seconds: UInt32; var dateTimeP: DateTimeType);
inline(SYSTRAP, sysTrapTimSecondsToDateTime); // with the secont parameter passed by reference with the keyword var
Ecrire à Philippe   Poster une réponse  Haut
Réponse n° 3
--------
le 24/09/2010 @ 10:42
par dearjohn

Anonyme


I tried it both, with and without pointer, and both solutions are working properly!

Thanks a lot.

Reinhard.

Ecrire à dearjohn   Poster une réponse  Haut
actif sujet actif   clos sujet clos   Important! Important!   Nouveau Nouveau message   -   Rectifier Rectifier message   Cloturer Cloturer sujet   Remonter Remonter
[]
Catégories de discussion  Forum 




^ Haut ^