Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Strange Behavior
Message
De
21/08/1998 13:33:36
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00128823
Message ID:
00128853
Vues:
18
>The following code is involved in an application I'm trying to distribute, but it is behaving differently depending on where it is run from. I can't understand why.
>
>Assume a directory structure like this:
>
>C:
> \DIR1
> \DIR2
> \FIRST
> \BASE
>
>The program is run from a directory (C:\DIR1) containing a .DBF called 'filloc' in it. The contents of the 'data' field contain a path (for this example, 'C:\DIR2\FIRST\'). The commands are then simply to go up one level (to DIR2) and then down into the sub-directory BASE where the program will contiue.
>
>I put in the 'test' window for debugging and that's when the odd behavior really began.
>
>Here are 3 scenarios:
>
>1) If I run the program from within VFP, it executes perfectly.
>
>2) If I create an executable and put it in C:\DIR1 and run it, the messages that show up in the test window are all the same: 'C:\DIR2\FIRST'. For some reason, the 'CD ..' command has no effect in this case. I get an 'Invalid path or filename' error after the second message because the program is trying to change to 'BASE' directly from 'FIRST'.
>
>3) If I put the executable in a separate directory on another drive with the line 'SCREEN = OFF' in the CONFIG.FPW file, it doesn't show the 'test' window at all, but it runs fine.
>
>Any help with this would be greatly appreciated as it has me completely baffled.
>
> TIA,
> Rob
>
>Here's the code:
>
>DEFINE WINDOW test;
> FROM 20,40 TO 30,100;
> IN DESKTOP;
> TITLE 'Current Directory'
>
>ACTIVATE WINDOW test
>
>USE filloc
>m.home=RTRIM(filloc.data)
>SET DEFAULT TO (m.home)
>
>? FULLPATH(CURDIR())
>WAIT '' TIMEOUT 1
>
>CD ..
>
>? FULLPATH(CURDIR())
>WAIT '' TIMEOUT 1
>
>CD base
>
>? FULLPATH(CURDIR())
>WAIT '' TIMEOUT 1
>
>RELEASE WINDOW test
Rob,
Never trust to Fullpath() and CD. ie: Fullpath() returns current dir when a nonexistent file is the parameter (sys(5)+curdir() is perfect for fullpath(curdir()) ). Instead of CDing just use :
set default to (cNewPath)
cNewPath could be "..\BASE" when you're in c:\DIR2\FIRST. Works in executable also.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform