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 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!weretis.net!feeder6.news.weretis.net!nntp.club.cc.cmu.edu!micro-heart-of-gold.mit.edu!newsswitch.lcs.mit.edu!nntp.TheWorld.com!.POSTED!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Need some help in Ada Date: Wed, 23 Mar 2016 17:06:30 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <2b215924-fdb7-4f58-b496-018ab837feec@googlegroups.com> NNTP-Posting-Host: shell02.theworld.com Mime-Version: 1.0 Content-Type: text/plain X-Trace: pcls7.std.com 1458767167 25563 192.74.137.72 (23 Mar 2016 21:06:07 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Wed, 23 Mar 2016 21:06:07 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:iGn1YASGd4tM9Egor21aQeRuTjg= Xref: news.eternal-september.org comp.lang.ada:29866 Date: 2016-03-23T17:06:30-04:00 List-Id: danifreecs@gmail.com writes: > Thank you for the reply! So it should be Components: String(1..Size)? Yes. > then i wrote this: > function Create(Str : String) return J_String is > Jstr: J_String(Str'Length); > begin > if (Str'Length = 0) then > Jstr.Components := ""; > else > Jstr.Components := Str; > end if; > return Jstr; > end Create; That looks like it will work, although you should try to format it in a more standard way. But it's more complicated than it needs to be. You don't need to special case the empty string. A single return statement, returning an aggregate, will work: return (Size => ..., Components => ...); I think you can figure out what the "..." parts should be. > when i try to use it like: jstr1: J_String(4) := Create("doge"); > i get this error "expected private type ada.text_io.file_type" which > i can't really understand. That's a visibility problem. Your Create is not directly visible, but the Create in Ada.Text_IO is, so the compiler thinks you want the latter. You need a "use" clause, or you need to say J_String_Pkg.Create(...). By the way, you don't want that "4": jstr1: J_String := Create("doge"); or maybe: jstr1: constant J_String := Create("doge"); Let the program figure out the length. You shouldn't have to count the number of characters in "doge". - Bob