Board index » delphi » i need help on pascal anyone can help?

i need help on pascal anyone can help?

My probs is i have create a file record call cutst.dat it has 6 records and
i need to read each record from cust.dat into an array of reocds. I have on
idea how to do the array.
Anyone can help would be good
thank you

 

Re:i need help on pascal anyone can help?


Quote
"DAVID LOH" <l...@microtech.com.au> wrote:
>My probs is i have create a file record call cutst.dat it has 6 records and
>i need to read each record from cust.dat into an array of reocds. I have on
>idea how to do the array.
>Anyone can help would be good
>thank you

Hi David,

You haven't told us the structure of the data file or provided any of
your work so we don't know if you are having problems defining the
array, defining the record, subscripting the array, reading the file,
assigning values to the fields, etc.

I'll make a WAG and assume the file is text and that you don't know
how to extract the field data.  Suggest you read the line into a
string variable, then use copy() to extract the individual fields.
You will probably also need to use val() to convert text into integer
and/or real values.

BTW, val() will {*word*88} if the field contains trailing spaces.  This
won't be a problem if the data is right-justified, however it would be
better to include code to remove trailing spaces.  A beginner's
solution would be:
    While (s[Length] = ' ') do
       s := Copy(s, 1, Length(s)-1);
or
    While (s[Length] = ' ') do
       Delete(s, Length(s), 1);

An advanced solution that is based on the fact that the string length
is at s[0]:
    While (s[Length] = ' ') do
       Dec(s[0]);

Hope this helps.  Next time provide a sample of your work and be more
specific in stating your problem.  It'll help us help you. ;-)

    ...red

Other Threads