URGENT reading file sequentially - driving me to despair 
Author Message
 URGENT reading file sequentially - driving me to despair

This is driving me absolutely mad!

Reading 2 files. One is keyed on record ascending sequence, the other
descending sequence.

read first file to end using:

close(file1)
open(file1)
Key=xxx
set(key,key)
next(file1)
loop
...
end
close(file1)

then i try to read other file doing exactly the same and have checked that I
am reading file2, including the next.

No matter what I do, it refuses anything other than read the first file
twice.

What on earth am I doing wrong.

--

JOHN FLIGG

C55EE, ABC (none Legacy)



Tue, 23 Dec 2003 04:13:06 GMT  
 URGENT reading file sequentially - driving me to despair
Have you tried a PREVIOUS instead of NEXT on file2?

Quote:

> This is driving me absolutely mad!

> Reading 2 files. One is keyed on record ascending sequence, the other
> descending sequence.

> read first file to end using:

> close(file1)
> open(file1)
> Key=xxx
> set(key,key)
> next(file1)
> loop
> ...
> end
> close(file1)

> then i try to read other file doing exactly the same and have checked that I
> am reading file2, including the next.

> No matter what I do, it refuses anything other than read the first file
> twice.

> What on earth am I doing wrong.

> --

> JOHN FLIGG

> C55EE, ABC (none Legacy)

--

Paul P. Gutelius
Base2 Corporation
Suite 304
1245 Cheyenne Avenue
Grafton, WI 53024
Voice (262) 387-1140
Fax   (262) 387-1150

AutoLine - EDI and beyond....
Visit our web site at WWW.Base2.com
  ~~~~~~~
Political contributions pay.
Ask Microsoft.
~~~~~~~



Tue, 23 Dec 2003 05:04:43 GMT  
 URGENT reading file sequentially - driving me to despair
1. What happens if you comment out the first file loop -- does this
force the second file loop to be performed?
2. The snippet you gave is a little too brief for me.  Particularly I
would have put the next() inside the loop.
3. Why are you doing a close() - open() - close()?
4. Below I enclose a code fragment. If it didn't work I would be
screaming, too.

clear(fyl1:record)
fyl1:key1=whatever1
set(fyl1:key1,fyl1:key1)
loop
        next(fyl1)
        if errorcode() then break.
        do things1
.

clear(fyl2:record)
fyl2:key1=whatever2
set(fyl2:key1,fyl2:key1)
loop
        next(fyl2)
        if errorcode() then break.
        do things2
.

Hope it helps.

--end--



Tue, 23 Dec 2003 05:31:01 GMT  
 URGENT reading file sequentially - driving me to despair
Got the little sod at last.

Can someone explain please ......

Right the file is 14 records long in this case. I read each record in turn
and after reading record 14 I knew I had to read backwards. So the pointer
is on record 14 which is also end of file.

It seems that at this point, the file has to be reset as previous produces
error code 33.

What I did therefore was at the end of record 14, I issued a set(key,key) to
force the file into some sort of order, having put 2 keys on the file again.
So loops 1,3,5 use forward key, loops 2,4,6 use the backwards key and all is
OK.

But WHY when the pointer is at record 14 does previous not point to 13?

Obviously same problem with old code.

So not a complete waste of time as I hope I will learn something fundamental
here and also had the oportunity to rastionalise codes significantly.

Thanks for the trouble though.

--

JOHN FLIGG

C55EE, ABC (none Legacy)

Quote:
> This is driving me absolutely mad!

> Reading 2 files. One is keyed on record ascending sequence, the other
> descending sequence.

> read first file to end using:

> close(file1)
> open(file1)
> Key=xxx
> set(key,key)
> next(file1)
> loop
> ...
> end
> close(file1)

> then i try to read other file doing exactly the same and have checked that
I
> am reading file2, including the next.

> No matter what I do, it refuses anything other than read the first file
> twice.

> What on earth am I doing wrong.

> --

> JOHN FLIGG

> C55EE, ABC (none Legacy)



Tue, 23 Dec 2003 06:38:57 GMT  
 URGENT reading file sequentially - driving me to despair
Do you blank the key nodes before the Set(key)? Need to.

--

Steve Parker
[Team Topspeed - Internet Connect]

-------------------------------------------------------------
Knowledge base: www.par2.com/cws/c5launch.dll/faqs/thefaqs.exe.0
Download center: www.par2.com/cws/c5launch.dll/d7.exe.0
--------------------------------------------------------------


Quote:
> Got the little sod at last.

> Can someone explain please ......

> Right the file is 14 records long in this case. I read each record in turn
> and after reading record 14 I knew I had to read backwards. So the pointer
> is on record 14 which is also end of file.

> It seems that at this point, the file has to be reset as previous produces
> error code 33.

> What I did therefore was at the end of record 14, I issued a set(key,key)
to
> force the file into some sort of order, having put 2 keys on the file
again.
> So loops 1,3,5 use forward key, loops 2,4,6 use the backwards key and all
is
> OK.

> But WHY when the pointer is at record 14 does previous not point to 13?

> Obviously same problem with old code.

> So not a complete waste of time as I hope I will learn something
fundamental
> here and also had the oportunity to rastionalise codes significantly.

> Thanks for the trouble though.

> --

> JOHN FLIGG

> C55EE, ABC (none Legacy)


> > This is driving me absolutely mad!

> > Reading 2 files. One is keyed on record ascending sequence, the other
> > descending sequence.

> > read first file to end using:

> > close(file1)
> > open(file1)
> > Key=xxx
> > set(key,key)
> > next(file1)
> > loop
> > ...
> > end
> > close(file1)

> > then i try to read other file doing exactly the same and have checked
that
> I
> > am reading file2, including the next.

> > No matter what I do, it refuses anything other than read the first file
> > twice.

> > What on earth am I doing wrong.

> > --

> > JOHN FLIGG

> > C55EE, ABC (none Legacy)



Tue, 23 Dec 2003 07:55:19 GMT  
 URGENT reading file sequentially - driving me to despair
Hi John!

Quote:
> But WHY when the pointer is at record 14 does previous not point to 13?

When you read record 14 out of 14, the pointer has passed the end of file
and therefore does not point anywhere. If you had 15 records and read
record 14, you would be pointing at record 15, an existing record, and
THEN PREVIOUS() should read record 14.

-- Craig (The Data Ferret)
http://www.pcferret.com/ for RARS, NetClip
http://www.pcferret.com/teletools.html for Telephony
http://www.pcferret.com/gps.html for GPS!
Virtual Access 5.51 build 315 Win98
http://counter.li.org ID #184149
"Do not meddle in the affairs of FERRETS..."



Tue, 23 Dec 2003 17:22:42 GMT  
 URGENT reading file sequentially - driving me to despair
Hi John,

On Thu, 5 Jul 2001 21:13:06 +0100, "John Fligg"

Quote:

>Reading 2 files. One is keyed on record ascending sequence, the other
>descending sequence.

>read first file to end using:

>close(file1)
>open(file1)
>Key=xxx
>set(key,key)
>next(file1)
>loop
>...
>end
>close(file1)

>then i try to read other file doing exactly the same and have checked that I
>am reading file2, including the next.

>No matter what I do, it refuses anything other than read the first file
>twice.

Is this the same file that you are just reading forward and then
backward or is this two separate files?  It's not 100% clear from your
post.

This should do it:

Clear(MYF:Record)
Set(MYF:Key)
Loop
  Next(MyFile)
  If ErrorCode()
    Break
  End
End

Clear(MYF:Record)
Set(MYF:Key)
Loop
  Previous(MyFile)
  If ErrorCode()
    Break
  End
End

If you are range limiting, you need to change the beginning to:

Clear(MYF:Record,-1) ! -1 for the Next(), +1 for the Previous()
MYF:KeyField = somevalue
Set(MYF:Key,MYF:Key)
Loop
  Next(MyFile)
  If ErrorCode() Or MYF:KeyField <> somevalue
    Break
  End
End

Best regards,

Arnr Baldvinsson        
San Antonio, Texas, USA
www.icetips.com & www.candobidding.com

ICQ:  113314380



Wed, 24 Dec 2003 23:52:22 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. How to read a xml-file sequentially

2. Reading values sequentially

3. Urgent help needed reading txt file

4. VSAM: Accessing file sequentially and dynamically in same program

5. Copy file from network drive to local drive?

6. URGENT URGENT URGENT

7. Despaired with GemStone

8. Student in Despair

9. Despairing Columnists Go Over the Edge

10. How can I read the Hard drive's Serial Number

11. Read Hard Drive ID

12. LPM 2.5, Error reading Drive C:

 

 
Powered by phpBB® Forum Software