Recent

Author Topic: trouble reading a ile  (Read 634 times)

stratocruiser

  • Newbie
  • Posts: 3
trouble reading a ile
« on: September 22, 2020, 11:55:29 am »
Hi,
I am having trouble reading a simple file that was created originally in VisualBasic. Trouble is the file contains both strings and integers. I can type the file from a command prompt, but all attempts to read it line-by -line in Lazarus fails. It seems I cant read a "text" file with a mixture of types. I have included a copy of the file. It is called "saviour.txt" Originally the original basic program created a data file called dvdcat using the record type. Initially, I copied the original record type into lazarus, but it also didn't work, yet I got a Ada program to read it. I have also included those files as well.  I would be very grateful if anyone could provide some assistance.

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: trouble reading a ile
« Reply #1 on: September 22, 2020, 12:01:07 pm »
You only included a pascal file.

Since the forum software does not accept all file types you should pack all file into a shared zip. In case of source code do not include compiler generated files such as exe, ppu, o, compiled etc because this may exceed the upload limit.

Handoko

  • Hero Member
  • *****
  • Posts: 5153
  • My goal: build my own game engine using Lazarus
Re: trouble reading a ile
« Reply #2 on: September 22, 2020, 12:53:47 pm »
Trouble is the file contains both strings and integers. I can type the file from a command prompt, but all attempts to read it line-by -line in Lazarus fails. It seems I cant read a "text" file with a mixture of types.

For that mix-types file you mentioned, you should read it as binary files, unless you convert the integer to string before saving it.

You can find some demos of basic file accessing under File handling section in the link below:
https://wiki.freepascal.org/Portal:HowTo_Demos

There has a binary file demo, which maybe is what you need.

stratocruiser

  • Newbie
  • Posts: 3
Re: trouble reading a ile
« Reply #3 on: September 22, 2020, 03:55:28 pm »
Thank you.

Appreciate your comments. I will convert all to strings.

Thaddy

  • Hero Member
  • *****
  • Posts: 14373
  • Sensorship about opinions does not belong here.
Re: trouble reading a ile
« Reply #4 on: September 22, 2020, 04:44:29 pm »
Thank you.

Appreciate your comments. I will convert all to strings.
VB has records too. If you would send the VB code you do not have any problems getting it solved here.
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

 

TinyPortal © 2005-2018