From: agent@drrob1.com
Subject: need help learning Ada for a modula-2 programmer
Date: Mon, 27 Jan 2014 20:06:43 -0500
Date: 2014-01-27T20:06:43-05:00 [thread overview]
Message-ID: <l90ee99ngsun16ec498p60nm3s0ah29r47@4ax.com> (raw)
The following code does not compile. I don't understand why.
The string processing fails to compile, saying "prefix of image must
be a type"
and
"move is undefined"
I don't yet understand string processing with Ada
--rob
with Ada.Calendar; use Ada.Calendar;
Package timliba is
-- REVISION HISTORY
-- ----------------
-- 6 Oct 13 -- Converted to gm2. And changed its name.
-- 19 Jan 14 -- Converted to Ada.
SubType String10Type is String(1..10);
TYPE DAYNAMESType is ARRAY (1..7) OF String10Type;
TYPE MONTHNAMESType is ARRAY (1..12) OF String10Type;
Type DateTimeType is RECORD
SystemTime: Time;
month,day,year,hours,minutes,seconds : Natural;
ElapsedSec : Duration;
END Record;
DateTime: DateTimeType;
DAYNAMES : Constant DayNamesType := ("Sunday ","Monday
","Tuesday ","Wednesday ", "Thursday ","Friday ","Saturday ");
MONTHNAMES : Constant MonthNamesType := ("January ","February
","March ","April ","May ",
"June ","July ","August ","September ","October
","November ","December ");
PROCEDURE TIME2MDY(M,D,Y : Out Natural);
-- System Time To Month, Day, and Year Conversion.
Procedure GetDateTime(DateTime: Out DateTimeType);
-- DateTimeType is my record time type containing everything.
Function JULIAN(M,D,Y : Natural) return Natural;
PROCEDURE GREGORIAN(Juldate : Natural; M,D,Y : OUT Natural);
END timliba;
-- with environa; use environa;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
with Ada.Characters; use Ada.Characters;
with Ada.Characters.Conversions; use Ada.Characters.Conversions;
with Ada.Characters.Handling; use Ada.Characters.Handling;
with Ada.Characters.Latin_1; use Ada.Characters.Latin_1;
with Ada.Calendar; use Ada.Calendar;
Package body timliba is
-- REVISION HISTORY
-- ----------------
-- 14 Apr 92 -- Created JULIAN and GREGORIAN procs, which are
accurate beyond 3/1/2100.
-- 25 Jul 93 -- Changed GREG2JUL and JUL2GREG limits to those imposed
by the
-- algorithm, ie, only years <2100 are now allowed.
-- 25 Jul 94 -- Changed limits of allowed years to 1700 from 1900.
-- 10 Nov 02 -- Converted to SBM2 Win v4.
-- 17 May 03 -- First Win32 version.
-- 26 May 03 -- Adjusted algorithm for Julian fcn so year has a
pivot.
-- 6 Oct 13 -- Converted to gm2.
-- 19 Jan 14 -- Converted to Ada.
SubType String255 is String(1..255);
K,IDX,PTR,c,RETCOD : Natural;
CH : CHARacter;
FLAG,FLAG2,FLAG3,FLAG4,FLAG5,EOFFLG : BOOLEAN;
-- PROMPT,NAMDFT,TYPDFT,INFNAM,OUTFNAM,
-- TMPBUF,NUMBUF,DRVPATH,INBUF,TOKEN : BUFTYP;
-- TKNSTATE : FSATYP;
I,J : INTEGER;
TYPE ADIPMType is ARRAY (0..11) OF INTEGER;
-- This is a typed constant that represents the difference btwn the
last day
-- of the previous month and 30, assuming each month was 30 days
long.
-- The variable name is an acronym of Accumulated Days In Previous
Months.
ADIPM : CONSTant ADIPMType := (0,1,-1,0,0,1,1,2,3,3,4,4);
FUDGEFACTOR : CONSTant LONG_FLOAT := 5.0;
-- These are declared in the spec file
-- Type DateTimeType is RECORD
-- SystemTime: Time;
-- month,day,year,hours,minutes,seconds : Natural;
-- ElapsedSec : Duration;
-- END Record;
PROCEDURE TIME2MDY(M,D,Y : Out Natural) is
-- *********************************** TIME2MDY
*************************
-- System Time To Month, Day, and Year Conversion.
Systime : Time;
BEGIN
Systime := Clock;
M := Month(Systime);
D := Day(Systime);
Y := Year(Systime);
END TIME2MDY;
Procedure GetDateTime(DateTime : Out DateTimeType) is
CardSec : Natural;
BEGIN
DateTime.SystemTime := Clock;
Split(DateTime.SystemTime,DateTime.year,DateTime.month,DateTime.day,DateTime.ElapsedSec);
CardSec := Natural(DateTime.ElapsedSec+0.5);
DateTime.hours := CardSec / 3600;
CardSec := CardSec - DateTime.hours * 3600;
DateTime.minutes := CardSec / 60;
DateTime.seconds := CardSec MOD 60;
END GetDateTime;
PROCEDURE MDY2STR(M,D,Y : Natural; MDYSTR : Out String255) is
-- ***************************** MDY2STR
*********************************
-- Month Day Year Cardinals To String.
DateSepChar : constant character := '/';
MSTR,DSTR,YSTR : String(1..2);
IntermedStr : String(1..10);
m0,d0,y0 : Natural;
BEGIN
m0 := M;
d0 := D;
y0 := Y;
IntermedStr := m0'Image & DateSepChar & d0'Image & DateSepChar &
y0'Image;
-- DSTR := D'Image;
-- YSTR := Y'Image;
-- MDYSTR := To255(IntermedStr);
Move(IntermedStr,MDYstr);
END MDY2STR;
Function JULIAN(M,D,Y : Natural) return Natural is
M0,D0,Y0 : Natural;
Juldate : Natural;
BEGIN
IF Y < 30 THEN
Y0 := Y + 2000 - 1;
ELSIF Y < 100 THEN
Y0 := Y + 1900 - 1;
ELSE
Y0 := Y - 1;
END IF;
IF (M < 1) OR (M > 12) OR (D < 1) OR (D > 31) OR (Y < 1700) OR (Y >
2500) THEN
-- Month, Day or Year is out of range
Juldate := 0;
RETURN(Juldate);
END IF;
M0 := M - 1;
Juldate := Y0 * 365 -- Number of days in previous normal years
+ Y0 / 4 -- Number of possible leap days
- Y0 / 100 -- Subtract all century years
+ Y0 / 400 -- Add back the true leap century years
+ ADIPM(M0) + M0 * 30 + D;
IF ((( Y MOD 4 = 0) AND ( Y MOD 100 /= 0)) OR ( Y MOD 400 = 0)) AND
-- 123 3 3 32 2 21
(M >
2) THEN
Juldate := Juldate + 1;
END IF;
RETURN Juldate;
END JULIAN;
PROCEDURE GREGORIAN(Juldate : Natural; M,D,Y : OUT Natural) is
Y0,M0,D0,L,JD : Natural;
BEGIN
Y0 := Juldate / 365;
M0 := 1;
D0 := 1;
WHILE JULIAN(M0,D0,Y0) > Juldate LOOP Y0 := Y0 - 1; END Loop;
M0 := 12;
WHILE JULIAN(M0,D0,Y0) > Juldate Loop M0 := M0 - 1; END Loop;
WHILE JULIAN(M0,D0,Y0) < Juldate Loop D0 := D0 + 1; END Loop;
M := M0;
D := D0;
Y := Y0;
END GREGORIAN;
END timliba;
next reply other threads:[~2014-01-28 1:06 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-28 1:06 agent [this message]
2014-01-28 1:33 ` need help learning Ada for a modula-2 programmer adambeneschan
2014-01-28 1:52 ` Jeffrey Carter
2014-01-28 12:18 ` Brian Drummond
2014-02-02 2:47 ` agent
2014-02-02 6:09 ` Jeffrey Carter
2014-02-02 15:02 ` agent
2014-02-02 16:00 ` gautier_niouzes
2014-02-02 19:48 ` Jeffrey Carter
2014-02-03 8:24 ` Dmitry A. Kazakov
2014-02-02 17:18 ` Brian Drummond
2014-02-03 0:10 ` agent
2014-02-03 0:36 ` agent
2014-02-03 12:53 ` Brian Drummond
2014-01-28 22:51 ` Jerry
2014-01-29 12:15 ` Mike H
2014-01-29 20:41 ` Jacob Sparre Andersen
2014-01-29 23:52 ` Jeffrey Carter
2014-01-30 9:05 ` Jacob Sparre Andersen
2014-01-30 14:20 ` Mike H
2014-01-30 14:35 ` Bill Findlay
2014-01-30 15:40 ` Mike H
2014-01-30 23:39 ` Jeffrey Carter
2014-01-31 20:16 ` Mike H
2014-01-29 23:52 ` Jeffrey Carter
2014-01-30 1:44 ` Bill Findlay
2014-01-30 2:01 ` Jeffrey Carter
2014-01-30 12:24 ` Simon Wright
2014-01-30 23:38 ` Jeffrey Carter
2014-02-03 23:12 ` agent
2014-02-04 6:10 ` J-P. Rosen
2014-02-04 22:38 ` agent
2014-01-29 16:58 ` Dirk Heinrichs
2014-01-29 20:43 ` Randy Brukardt
2014-01-29 22:53 ` Georg Bauhaus
2014-01-30 12:13 ` Simon Wright
2014-01-30 17:05 ` Dirk Heinrichs
2014-01-30 23:21 ` Randy Brukardt
2014-01-30 4:29 ` Nasser M. Abbasi
2014-01-30 8:45 ` Where to put change descriptions (Was: need help learning Ada for a modula-2 programmer) Jacob Sparre Andersen
2014-01-30 9:53 ` need help learning Ada for a modula-2 programmer Georg Bauhaus
2014-01-30 21:58 ` Randy Brukardt
2014-01-30 16:28 ` Pascal Obry
2014-01-30 17:43 ` Marius Amado-Alves
2014-01-30 18:10 ` Simon Wright
2014-01-30 22:38 ` Randy Brukardt
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox