From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.182.161.105 with SMTP id xr9mr12087905obb.31.1390871205130; Mon, 27 Jan 2014 17:06:45 -0800 (PST) Path: border1.nntp.dca.giganews.com!nntp.giganews.com!uq10no4605141igb.0!news-out.google.com!y18ni3442qap.1!nntp.google.com!news.glorb.com!news-in-01.newsfeed.easynews.com!easynews!core-easynews-01!easynews.com!en-nntp-05.dc1.easynews.com.POSTED!not-for-mail From: agent@drrob1.com Newsgroups: comp.lang.ada Subject: need help learning Ada for a modula-2 programmer Message-ID: User-Agent: ForteAgent/7.20.32.1218 MIME-Version: 1.0 X-Complaints-To: abuse@easynews.com Organization: Forte Inc. http://www.forteinc.com/apn/ X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly. Date: Mon, 27 Jan 2014 20:06:43 -0500 X-Received-Bytes: 6991 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Xref: number.nntp.dca.giganews.com comp.lang.ada:184581 Date: 2014-01-27T20:06:43-05:00 List-Id: 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;