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=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,4231869cc877ceb9 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-09-26 14:44:14 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!arclight.uoregon.edu!wn13feed!wn11feed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi.com!sccrnsc03.POSTED!not-for-mail From: tmoran@acm.org Newsgroups: comp.lang.ada Subject: Re: random number generation References: X-Newsreader: Tom's custom newsreader Message-ID: NNTP-Posting-Host: 12.234.124.41 X-Complaints-To: abuse@comcast.net X-Trace: sccrnsc03 1064612653 12.234.124.41 (Fri, 26 Sep 2003 21:44:13 GMT) NNTP-Posting-Date: Fri, 26 Sep 2003 21:44:13 GMT Organization: Comcast Online Date: Fri, 26 Sep 2003 21:44:13 GMT Xref: archiver1.google.com comp.lang.ada:43027 Date: 2003-09-26T21:44:13+00:00 List-Id: > the problem is I get errors such as > mazecreate.adb:18:04: statement not allowed in declarative part The compiler is trying to help you. It's telling you that line 18 has a statement, but it's in a declarative part, ie, a part where there are supposed to be just declarations. Looking at line 18, I see X:= Generator_Options.Random(A_Generator); which is an assignment statement, not a declaration. It's also the case that Ada programs are normally readable from top to bottom. Your's has A_Generator : Generate_Options.Generator; before you've declared what "Generate_Options" is, so you need to move A_Generator : Generate_Options.Generator; after package Generate_Options is new Ada.Numerics.Discrete_Random(Options); Of course you will also need to tell the compiler what Ada.Numerics.Discrete_Random is, by putting it in a "with" statement at the beginning of your program. What is X? A general integer, which can legitimately be negative or very large, and which can be added and multiplied by any other Integer? Or is X a code, say for card suits, or one of four symbols in maze, where adding two of them together or multiplying by -3, would make no sense. If it's a code, then you need X : Options; (after Options has been declared) instead of X : Integer; If X is a general purpose Integer, then type Options should be a subtype of Integer, not a full-fledged type of its own, ie, it should be: subtype Options is Integer range 1 .. 4; I notice your program does not actually use X anywhere. I presume that's because you just haven't gotten to coding that yet. A couple other notes: The Is_Open test right after Create is not really necessary. Either the file is open, or if there was a problem creating such a file Create would have raised an exception and you won't be executing the "if Is_Open" code. Having variables named "spot" and "spott" means that when you mistype one as the other the compiler won't be able to warn you, and you'll wonder why your program doesn't work right. Better to choose names so a simple typo will do something detectable by the compiler as an error.