Article View: comp.lang.modula2
Article #3405Re: help on longcard
From: Peter P. Eiserloh
Date: Thu, 21 Mar 1996 18:55
Date: Thu, 21 Mar 1996 18:55
53 lines
2793 bytes
2793 bytes
In article <vCnhuFASrJUxEwoQ@suko.demon.co.uk> Steve Perry, steve@suko.demon.co.uk writes: >I am seeking help solving a problem, I will at the outset own up to it >being a homework-help problem, but would add that the answer to this >does represent only a *very* small part of the task that I have to >complete! >Using FST Modula-2 I need to write, as a small part of an assignment, a >timer that takes as a starting point the number of seconds that have >elapsed since midnight. >This would entail storing a value <= 86400. >The GetTime procedure returns CARDINAL values for - minutes since >midnight and milliseconds past the minute. >I intended to use the following: >MyTime := GetTime((SysTime.minutes)*60)+(SysTime.millisec)/1000)); >However the result produced can be a value that requires a LONGCARD for >storage. >I have to date not been able to get the result into a VAR declared AS >LONGCARD. I have tried LONG(..) to no avail. >Have I missed something basic? A CARDINAL is stored in 2 bytes and a >LONGCARD in 4 bytes so why is there not a procedure to convert? >My tutor for this subject is not available for several days, none of my >text books offer an answer, so any help would be much appreciated. >regards I don't have immediate access to the FST def files, and trying to remember the peculiarities of FST, what you need is: MODULE Timer; FROM SYSTEM IMPORT LONG; PROCEDURE GetCurrentTime(VAR time : LONGCARD); (* --- Get current time in number of seconds from midnight --- *) VAR mins, millis : CARDINAL; BEGIN mins := GetMinsFromMidnight(); millis := GetMilliSecsFromMinute(); time := LONG(mins) * 60L + LONG(millis DIV 1000); END GetCurrentTime; END Timer. FST uses the non-standard suffix "L" to indicate literals which are LONG. I used the LONG() type transfer function from a hypothetical SYSTEM module. Newer compilers would do something like CAST(LONGCARD, mins). Hope this helps, all you have to do is insert the correct names for the functions which get the minutes, and milli-seconds from the OS. Peter -----
Technical Details
Message-ID:
<DoMsKr.C6o@avalon.chinalake.navy.mil>Path:
arc1-ca.pugleaf.net!rugeyes.chinalake.navy.mil!Peter_Eyes_EiserlohReferences:
<vCnhuFASrJUxEwoQ@suko.demon.co.uk>Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.modula2 Path: arc1-ca.pugleaf.net!rugeyes.chinalake.navy.mil!Peter_Eyes_Eiserloh From: Peter P. Eiserloh <Peter_Eyes_Eiserloh@WSSAGW.chinalake.navy.mil> Subject: Re: help on longcard Content-Type: text/plain; charset=ISO-8859-1 Message-ID: <DoMsKr.C6o@avalon.chinalake.navy.mil> X-Xxmessage-Id: <AD76E6D1720121C9@rugeyes.chinalake.navy.mil> X-Xxdate: Thu, 21 Mar 1996 17:58:25 GMT Sender: usenet@avalon.chinalake.navy.mil (NAWS news admin) Content-Transfer-Encoding: 8bit Organization: Naval Air Warfare Center - Weapons Division X-Newsreader: Nuntius 2.0.4_68K References: <vCnhuFASrJUxEwoQ@suko.demon.co.uk> Mime-Version: 1.0 Date: Thu, 21 Mar 1996 18:55:39 GMT