[Valentina] Re: Vdb files

Keith DeLong delong at redcort.com
Mon Jan 20 09:46:29 CST 2003


> on 1/20/03 6:31 PM, Keith DeLong at delong at redcort.com wrote:
> 
>> I still don't see why CREATE needs SUBSTR()...
> 
> You make me crazy.  :-)

I am persistent, aren't I ;-)
 
> And how you will make names of rest 3 files ???

This is a GREAT exercise. Please think through this with me. Instruct me
where I am in error...

> Okay. So we start app.
> We do 
> 
>   SetExtentions( "aaa", "bbb", "ddd", "ccc" )

> Show me logic now for:
> Db mode = 4
> 
> --------
>        Mac Classic         MAC X           Windows
> 
> 1) db.Create( "dbtest v1.2" )
  

(A) We've been told by REAL over and over it is WRONG to rely on absolute
paths for opening files.

(B) I must check for existence of file before opening it.

Both of these require me to have a folderitem that point to the actual file
I want to open or create

  NewFileLocation = SaveAsDiaslog.showModal
   if NewFileLocation <> nil then
     filename = NewFileLocation.name

     db = new vdatabase
     db.Creator = CreatorCode
     ValentinaSetExtensions "aaa", "bbb", "ddd", "ccc"
    
     Res = db.Create(filename,5,4096)
   end

Since I set SetExtentions( "aaa", "bbb", "ddd", "ccc" ), All 3 Classic, X
and Win32 will all 3 produce the same files and be fully cross platform
usable.

dbtest v1.2.aaa
dbtest v1.2.bbb
dbtest v1.2.ddd
dbtest v1.2.ccc


If I want no extensions in Mac only app, I do

SetExtentions( "", "bbb", "ddd", "ccc" )
Res = db.Create( "dbtest v1.2" )

dbtest v1.2
dbtest v1.2.bbb
dbtest v1.2.ddd
dbtest v1.2.ccc


> 2) db.Open( "dbtest v1.2" )
>       // must open at least the same file made by create above.

I must first verify CREATE() worked so I need a folderitem before attempting
to open it. Even in a new session, I need OPEN(folderitem.name) so I know
I'm asking RB to open anexisting and valid file.

If Res then //no error on create
  MyNewDatafileFolderItem.name = FileName + "aaa"   //this is awkward
  
   If MyNewDatafileFolderItem.name.exists
      dbOpen (MyNewDatafileFolderItem.name)
   End
End

It would be perfect if If create returned the new data file folderitem:

MyNewDatafileFolderItem = db.Create(filename,5,4096)

Or I would even settle access to the setextensions constants:

FileExtension = "aaa"
BlobExtension = "bbb"
DatExtension = "ddd"
IndexExtension = "ccc"

MyNewDatafileFolderItem.name = FileName + FileExtension

Can't you see how the current system is making me track the file extension
needlessly and can so easily produce unexpected errors and results?
 
> 3) db.Create( "dbtest v1.2.aaa" )
> 
>       // *** interesting how you will make here names of rest 3 files
>       // *** without substr ???

This is the unnecessary complication that I think should be done away with.

This would generate CONSISTENT but unwanted results since CREATE() is takes
a filename to which it will append the set or default extensions. So this
would wrongly generate code that is easy to see what happened and how to fix
it.

dbtest v1.2.aaa.aaa
dbtest v1.2.aaa.bbb
dbtest v1.2.aaa.ddd
dbtest v1.2.aaa.ccc
 
> 3) db.Open( "dbtest v1.2.aaa" )

Again, Passing a string to open is just asking for trouble since you've not
checked that it is a valid filename for a valid filepath.

I'd like Create(NewFileLocation.name)  //from save dialog
or
I'd like Create("My Name") I supply a new name

And it should always be Open(FileFolderItem.name)

Does this help you at all understand where I'm coming from?

Keith


 



More information about the Valentina mailing list