[Lazarus] reading FORTRAN-style input in Lazarus

Lukasz Sokol el.es.cr at gmail.com
Fri Aug 5 10:15:53 CEST 2011


> 
> On 8/5/2011 12:41 AM, Alexander Klenin wrote:
>> On Fri, Aug 5, 2011 at 15:06, David M. Lawrence<dave at fuzzo.com>
>> wrote:
>>> I've held on to FORTRAN because of its ability to explicitly
>>> define input (and output) formats -- this is a must for
>>> extracting data from a number of publicly available datasets.
>>> 
>>> I'm now trying to convert one of my most useful programs to
>>> PASCAL, but I am hung up on how to read multiple variables from a
>>> single line.
>>> 
>>> For example, here's a FORTRAN format I need to emulate:
>>> 
>>> FORMAT(I3,I7,2X,A25,1X,F6.2,1X,F7.2,3(1X,I4),1X,F4.1,1X,I1)
>>> 
>>> On a single line, I begin with two integer variables, skip two
>>> spaces, one string variable, one space followed by a real
>>> variable, skip a space, etc.
>>> 
>>> I know of examples that involve treating each line as a character
>>> array, but I cannot find them now.  I also know how to specify
>>> write formats, but have seen no examples of applying that to
>>> reading lines.
>>> 
>> If values are separated by spaces, you can just use Readln. If you
>> really need to check exact format (i.e. error out if there are, for
>> example, three spaces instead of two), you can re-format the values
>> read and compare result with the original string.
>> 
> 
On 05/08/2011 05:49, David M. Lawrence wrote:
> The values aren't always separated by spaces.  These are huge files
> with sometimes tens of thousands of lines of data.  The only way I
> can effectively search and extract relevant data form them is to find
> a way to specify that characters 1 through 3 are a country code,
> characters 13 through 37 are site names, etc.
> 
> Dave

So this is some kind of address database ?
Any real-world example you could provide with different field separators ?
(data may be dummy, of course)

L.





More information about the Lazarus mailing list