Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need code to change directory(alias), to switch between applications. 1

Status
Not open for further replies.

elevator

Programmer
Apr 23, 2002
19
US
Need code to change directory(alias)to switch between applications.

I have an application that I have to work around.
In order not to mix my files with theirs, I need
to switch from :their: alias to :my: alias.

Using:
f:\T for :their: alias
f:\M for :my: alias

I have a form in :their: alias that calls for the application form (Icycles) in :my: alias.

I think that my form (Icycles) should contain code to change the alias to :my: alias, also I would need to change it back to :their: alias, when I exit :my: alias
 
elevator,

Your best bet, in this case, is to use project aliases, which are not stored in the BDE32.CFG (or whatever it's called on your system).

In your Icycles form, you'll want to add two things:

1. A switch to select the appropriate definition. I'll assume you're using a field object defined as a set of two radio buttons. We'll call it fldAliasDrv and assume that the labels of the radio button contain the letters of the drives you want to switch between.

2. Add a button with code that a) deletes the target alias if it's already defined and b) redefines the alias based on the radio button you've selected. Something along these lines should work:

Code:
method pushButton(var eventInfo Event)
var
   strAlias  String
endVar

const
   ALIAS_NAME = "Xyzzy"
endConst

   ; if alias exists, remove it
   errorTrapOnWarnings( Yes )
   try
      strAlias = getAliasPath( ALIAS_NAME )
   onFail
      strAlias = ""
   endTry
   errorTrapOnWarnings( No )  ; optional

   if strALias <> &quot;&quot; then
      removeAlias( ALIAS_NAME )
   endIf

   ; Determine the new location and then 
   ; use that to define the alias.
   strAlias = fldAliasDrv.Value +
              &quot;:\\&quot;  ; add pathnames as needed

   if not addProjectAlias( ALIAS_NAME, &quot;Standard&quot;,
                           strAlias ) then
      errorShow( &quot;Alias Not Set&quot;, 
                 &quot;Click [>>] for details]...&quot; )
   endIf

endMethod

Note that I've added some error handling to this. You may or may not want that level of control. (Natrually, I'd suggest you want it, but it's worth reviewing in any event.)

Also, if you need to change directories to make this work, you may find helpful.

Hope this helps...

-- Lance
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top