Re. [Oberon] Library

Dan Parnete parnete at aladata.it
Wed Sep 3 22:05:18 CEST 2003


eas-lab at absamail.co.za wrote:

>Dan Parnete wrote:
>
>  
>
>>I should like to do that:
>>
>>PROCEDURE ReadLib*( f: Files.File, pos: LONGINT ): Objects.Library;
>>    VAR i, len: LONGINT;
>>             L: Objects.Library;
>>BEGIN
>>    NEW( L );  Objects.OpenLibrary( L );  Objects.LoadLibrary( L, f, 
>>pos+1, len );
>>    RETURN L
>>END ReadLib;
>>
>>But the result is:
>>
>>TRAP 7  Index out of range in thread Oberon.Loop
>>
>>Files.ReadString  PC = 7278
>>    R =  00411878H Files.Rider
>>    ch =  00000020X
>>    i = 64
>>    x = "                                                                
>>" ...
>>Objects.LoadLibrary  PC = 6475
>>    @for = 8223
>>    @for = 13
>>    L =  014E0200H Objects.LibDesc
>>    N = 8224
>>    R =  00411878H Files.Rider
>>    dict =  00000000H (Objects.ListDictDesc)
>>    dorg = 595
>>    entry =  00000000H (Objects.EntryDesc)
>>    f =  01C1CA20H Files.File
>>    gorg = 512
>>    i = 14
>>    ind =  014AAF40H Objects.ArrayIndexDesc
>>    key = 8224
>>    len = 597
>>    n = 0
>>    pos = 200017
>>    version = 1380272450
>>DpsDb.ReadLib  PC = 11734     <----- compare with source code
>>    L =  014E0200H Objects.LibDesc
>>    ch =  00000000X     <---- this does not correspond with code above
>>    f =  01C1CA20H Files.File
>>    fl =  00000000H (Files.File)
>>    i = 0
>>    len = 597
>>    rl =  00411878H Files.Rider
>>    size = 597
>>    
>>
>
>!! This trap info does not come from the code above !!
>
Yes, ch was declared there but not used, and I deleted it when I write 
the email.

>
>  
>
>>And is nothing wrong with the data because doing that:
>>
>>PROCEDURE ReadLib*( size: LONGINT; f: Files.File; r: Files.Rider ): 
>>Objects.Library;
>>    VAR i, len: LONGINT;
>>            ch: CHAR;
>>            fl: Files.File;  rl: Files.Rider;
>>            L: Objects.Library;
>>BEGIN
>>    fl := Files.New( "TempLib" );  Files.Set( rl, fl, 0 );
>>    FOR i:=0 TO size-1 DO Files.Read( r, ch );  Files.Write( rl, ch ) END;
>>    Files.Register( fl );  fl := Files.Old( "TempLib" );
>>    NEW( L );  Objects.OpenLibrary( L );  Objects.LoadLibrary( L, fl, 1, 
>>len );
>>    RETURN L
>>END ReadLib;
>>    
>>
>
>The trap info could be from this code.
>
No, was not from this one.

>
>My 2001 ver. of  Files.ReadString looks different.
>
>But I'm guessing that LEN(x) = 64   [0...63] and you had an overflow ?
>  
>
Yes, but why? I'm not controlling the LoadLibrary. And the data is 
correct, if the second version works.

I finally found the answer: you cannot LoadLibrary from a different 
position then was StoreLibrary. I was doing that: store Lib on a 
temporary file (pos=0), then insert the content of temp file in the 
database file (pos=200000 or more). When I tried to load Lib from the 
database, it ended in the Trap.
Now, the db engine LoadLib from the temp file and then StoreLib on the 
db file, and everything work fine.

Thank you for the suggestion,
Dan Parnete




More information about the Oberon mailing list