* Re: Please give me some hints... [not found] <9909pn$19j2@tech.port.ac.uk> @ 2001-03-17 22:51 ` chris.danx 2001-03-17 23:10 ` chris.danx 2001-03-21 18:18 ` Stephen Leake 1 sibling, 1 reply; 3+ messages in thread From: chris.danx @ 2001-03-17 22:51 UTC (permalink / raw) Look at line 9 'num_of_integer', then look at line 12. Then look at the warnings given by the compiler. If you do this you'll be able fix it. One hint: when an exception is raised the line number is given. Use this to track it down. In this case it was line 12. Chris Campbell "WWM" <wwminirl@hotmail.com> wrote in message news:9909pn$19j2@tech.port.ac.uk... > I have written a program: input 2 integers, output sorted integers > one-by-one by descending order. e.g. > > > Input an integer: 2 > Input another one: 7 > > The sorted integer is: 7 6 5 4 3 2 > > > > The problem is, when I run it, it says: STORAGE_ERROR > > Can any one help??? > > > > > ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Please give me some hints... 2001-03-17 22:51 ` Please give me some hints chris.danx @ 2001-03-17 23:10 ` chris.danx 0 siblings, 0 replies; 3+ messages in thread From: chris.danx @ 2001-03-17 23:10 UTC (permalink / raw) One thing i forgot. You can't use a variable for the the array bounds in many circumstances -- though there are some but your a beginner, right?. Maybe you should use a constant for this. I tried this by making num_of_integer a constant but it wouldn't compile, so i fixed the array bounds and tried to compile it. It didn't work! What i would suggest is you look at your spec. If i understand your program correctly you ask for the min/max numbers which are used to calculate num_of_integers. This then seems to be used as if it were the bounds of the array. You know there will be five number so this seems unneccessary. If your intention was to do something else, you may need to revise your design -- be it on paper or in your head. Hope this is helpful, Chris Campbell "chris.danx" <chris.danx@ntlworld.com> wrote in message news:STRs6.10259$bL.819321@news6-win.server.ntlworld.com... > Look at line 9 'num_of_integer', then look at line 12. > Then look at the warnings given by the compiler. > > If you do this you'll be able fix it. > > One hint: when an exception is raised the line number is given. Use this to > track it down. In this case it was line 12. > > > Chris Campbell > > > "WWM" <wwminirl@hotmail.com> wrote in message > news:9909pn$19j2@tech.port.ac.uk... > > I have written a program: input 2 integers, output sorted integers > > one-by-one by descending order. e.g. > > > > > > Input an integer: 2 > > Input another one: 7 > > > > The sorted integer is: 7 6 5 4 3 2 > > > > > > > > The problem is, when I run it, it says: STORAGE_ERROR > > > > Can any one help??? > > > > > > > > > > > > ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Please give me some hints... [not found] <9909pn$19j2@tech.port.ac.uk> 2001-03-17 22:51 ` Please give me some hints chris.danx @ 2001-03-21 18:18 ` Stephen Leake 1 sibling, 0 replies; 3+ messages in thread From: Stephen Leake @ 2001-03-21 18:18 UTC (permalink / raw) "WWM" <wwminirl@hotmail.com> writes: > I have written a program: input 2 integers, output sorted integers > one-by-one by descending order. e.g. > > > Input an integer: 2 > Input another one: 7 > > The sorted integer is: 7 6 5 4 3 2 > > > > The problem is, when I run it, it says: STORAGE_ERROR > num_of_integer : positive; type NUMBER_TYPE is array(POSITIVE range<>) of INTEGER; NUMBERS: NUMBER_TYPE(1..num_of_integer); --the array of numbers This code is your problem. Space for the variable NUMBERS is allocated at "elaboration time", which is before your code runs. So NUMBERS uses the value of 'num_of_integer', which is some random number, probably very large. > Can any one help??? You need to use a nested declare block: program unconstrained_sort is num_of_integer : positive; type NUMBER_TYPE is array(POSITIVE range<>) of INTEGER; ... begin Put("input an int"); get(max_int); put("input another"); get(min_int); num_of_integer := max_int - min_int; declare NUMBERS: NUMBER_TYPE(1..num_of_integer); begin -- call sort etc. end; end unconstrained_sort; Now 'num_of_integer' has a good value when it is used. -- -- Stephe ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2001-03-21 18:18 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <9909pn$19j2@tech.port.ac.uk> 2001-03-17 22:51 ` Please give me some hints chris.danx 2001-03-17 23:10 ` chris.danx 2001-03-21 18:18 ` Stephen Leake
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox