Re: Sequences (revisited)

new topic     » topic index » view thread      » older message » newer message

>On Sun, 8 Nov 1998 20:07:26 -0600, Jim Roberts <jhroberts1 at JUNO.COM> wrote:
>
>>In EUPHORIA I read a file that was written in FORTRAN and it has the
>>following format:
>><snip>
If your data files are of a random length:
   1   2   3   4
  12  13  14  15  16  17
 110 111 112
4321432243234324
  99

Here's a revised version to handle this situation:
include get.e -- for value function

constant fi = 4 -- declare the length of a fortran integer

object input
sequence n, nums
atom fn

fn = open("test.dat","r")
nums = {}
while 1 do
   input = gets(fn)
   if atom(input) then exit
   elsif length(input) < fi then exit

   else
   puts(1,"Line in:" & input)
   for i = 1 to (length(input)-fi) by fi do
       n = value(input[i..i+fi-1])
       nums = append(nums,n[2])
   end for
   end if
   puts(1,"Converted:") ? nums
end while

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu