comp.lang.ada
 help / color / mirror / Atom feed
* weird compilation error...
@ 2004-01-08 20:33 Qas
  2004-01-08 21:13 ` Robert A Duff
  0 siblings, 1 reply; 2+ messages in thread
From: Qas @ 2004-01-08 20:33 UTC (permalink / raw)


hello all,

(pascal) me again.bdw it wasn't hmwk last time just an excercise the
tutor hadnt talked about and wanted us to give a try in spare time.!

any how, i have this program and i want to enter the string i read
using get_line into an array. this how the program looks like(so far):

-------------------------------------
PROCEDURE Search1 IS

--subtype filename is string(1..3500);
--   File:Filename;
   
   Max_Chars:Integer:=37;
   Current_Line:String(1..Max_Chars);
   
   SUBTYPE Stringy IS String (1..37);
   TYPE Key_Array IS ARRAY (1 .. 101) OF stringy;
   Files:Key_Array;

   Line:Natural;
   Count:Integer:=0;
   Blank:CONSTANT Character:=' ';

   Words:Integer:=0;
   
   
BEGIN
   Openinput(Filename=>"filelist.txt");
   --openoutput(filename=>"result.txt");
   
   WHILE NOT End_Of_File LOOP
      Get_Line(Item=>Current_Line, Last=>Line); --| i want to enter
this line into 1 element of the above array.how?
      Put_Line(Item=>Current_Line(1..Line));
      files:=current_line; --| here the compilation error occurs
      Count:=Count+1;

   END LOOP;
   new_line;Put("COUNT  ");Put(Count);

   Closeinput;
   --closeoutput;
   END Search1;
-------------------------------------------

now the compilation error is this: 

search1.adb:33:14: expected type "Key_Array" defined at line 16
search1.adb:33:14: found type "Standard.String"

now what does it mean by expected Key_array because as far as i can
understand the key_array is a string array. or are string arrays not
possible? if theyre not then will a record work?

so any other way of doing this

this is the format of the input file:

xxxxxxxyyyyyy         EOL
sssssskkkkkkkdddddsss EOL
fffffffdddddd         EOL
ffffffffffffffff      EOL

each line is max 36 char but can be less

thanks for reading.
Qas



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: weird compilation error...
  2004-01-08 20:33 weird compilation error Qas
@ 2004-01-08 21:13 ` Robert A Duff
  0 siblings, 0 replies; 2+ messages in thread
From: Robert A Duff @ 2004-01-08 21:13 UTC (permalink / raw)


mmq_2002@onetel.net.uk (Qas) writes:

> now the compilation error is this: 
> 
> search1.adb:33:14: expected type "Key_Array" defined at line 16
> search1.adb:33:14: found type "Standard.String"
> 
> now what does it mean by expected Key_array because as far as i can
> understand the key_array is a string array. or are string arrays not
> possible? if theyre not then will a record work?

An array-of-string is not a string.  You need to count the line numbers
as you read them in, and assign into each component separately.

By the way, type String is a pain, because each String is fixed length.
And you can't have an array of different-length Strings.  Your program
will be more flexible and easier to write if you use an Unbounded_String
instead.

- Bob



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-01-08 21:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-08 20:33 weird compilation error Qas
2004-01-08 21:13 ` Robert A Duff

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox