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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.98.76.210 with SMTP id e79mr2991133pfj.4.1458764643747; Wed, 23 Mar 2016 13:24:03 -0700 (PDT) X-Received: by 10.157.35.14 with SMTP id j14mr57026otb.8.1458764643655; Wed, 23 Mar 2016 13:24:03 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!news.mixmin.net!news.glorb.com!w104no8417128qge.1!news-out.google.com!b22ni1539qge.1!nntp.google.com!w104no8417126qge.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 23 Mar 2016 13:24:03 -0700 (PDT) In-Reply-To: <2b215924-fdb7-4f58-b496-018ab837feec@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=85.238.64.35; posting-account=WGwmlQoAAADDeUXb_cIKMah4KZlJkq5i NNTP-Posting-Host: 85.238.64.35 References: <2b215924-fdb7-4f58-b496-018ab837feec@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Need some help in Ada From: danifreecs@gmail.com Injection-Date: Wed, 23 Mar 2016 20:24:03 +0000 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:29864 Date: 2016-03-23T13:24:03-07:00 List-Id: 2016. m=C3=A1rcius 23., szerda 20:51:40 UTC+1 id=C5=91pontban Anh Vo a k=C3= =B6vetkez=C5=91t =C3=ADrta: > On Wednesday, March 23, 2016 at 12:29:05 PM UTC-7, danif...@gmail.com wro= te: > > Hello there! > >=20 > > I'm a student, and i've got my 1st home project in Ada. I need to imple= ment a J_String package with a lot of functions etc, but i have problems at= the start. The specification asks me to "implement J_String type as an opa= que discriminant record type. For the inner representation of the string us= e the Standard String type. The discriminant determines the size of the str= ing, which is contained in the J_String type." > >=20 > > My .ads at the moment: > >=20 > > package J_String_Pkg is > > type J_String(Size: Natural) is private; > > private > > type J_String(Size: Natural) is record > > Components: String(Natural Range 0..Natural'Last); > > end record; > > end J_String_Pkg; > >=20 > > I don't know if the above is good, but the main reason i'm asking help = is the following methods: > > function Create(Str : String) return J_String; > > --Creates a J_String from a String > > function Value_Of(S : J_String) return String; > > --Returns the content of S in String type > > function Is_Empty(S : J_String) return Boolean;=20 > > -- Returns true if, and only if, length() is 0. > >=20 > > I think i can do the other 20+ methods, but i can't figure out how to m= ake my J_String type to be able to create empty strings. Thanks for every h= elp! >=20 > Empty string means string length is 0. That means upper string index is l= ess than lower string index. For example, an empty predefined string looks = like this. >=20 > Empty_String : String (1 .. 0) :=3D ""; >=20 > By the way, now you can see why the record field Components is not correc= t.=20 >=20 > Anh Vo Thank you for the reply! So it should be Components: String(1..Size)? then i wrote this: function Create(Str : String) return J_String is Jstr: J_String(Str'Length); begin=09 if (Str'Length =3D 0) then Jstr.Components :=3D ""; else Jstr.Components :=3D Str; end if; return Jstr; end Create; when i try to use it like: jstr1: J_String(4) :=3D Create("doge"); i get this error "expected private type ada.text_io.file_type" which i can'= t really understand.