gettingstarted
[Top] [All Lists]

Re: Conditional Creation of Files and Folders

To: Getting Started <gettingstarted at lists dot realsoftware dot com>
Subject: Re: Conditional Creation of Files and Folders
From: Jonathan Johnson <jonj at realsoftware dot com>
Date: Fri, 28 May 2004 22:53:28 -0500
Delivered-to: gettingstarted at lists dot realsoftware dot com
List-help: <mailto:gettingstarted-request@lists.realsoftware.com?subject=help>
List-id: Getting Started <gettingstarted.lists.realsoftware.com>
List-post: <mailto:gettingstarted@lists.realsoftware.com>
References: <1d2 dot 223b6870 dot 2de95d3b at aol dot com>

On May 28, 2004, at 10:27 PM, GAmoore at aol dot com wrote:

This is sort of related to my last question. I want to make a "Settings" folder in the same locale as the application - if it doesn't exist create, if it
does exist, then put files into it. I'm a little confused as to the
create/connection distinction in this case. Similarly, with databases .... I read the examples for creating a new database or opening an existing one. However, how can
you open it if it exists, create it if it does not exist?

if dbFile.exists then
 // it exists
else
 // it doesn't exist
end if

//...- this would make it easier to modularize that operation, but how do
you pass the db references?

Declare a method with the parameter "db as Database". Just pass it then.

//do DB stuff here for both cases (connected to existing, or just
created) - knowing that you
// can't get here in bad cases (not created or not connected) -
however this leaves me feeling
// like there might be some case where the control can somehow
sneak into this part of code

If you ever have an error, feel free to use the "return" statement to leave the function. For example:

if not db.Connect then
  MsgBox "Couldn't connect."
  return
end if

// go on your merry way

If it couldn't connect, it won't ever get past that return statement.

HTH,
Jon


--
Jonathan Johnson
Testing Department
REAL Software, Inc.

_______________________________________________
Unsubscribe or switch delivery mode:
<http://support.realsoftware.com/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>