Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP Command SYS(5)
Message
From
26/10/2004 01:33:26
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 6 SP5
OS:
Windows '98
Network:
Windows 98
Database:
Visual FoxPro
Miscellaneous
Thread ID:
00954436
Message ID:
00954465
Views:
11
>On a workstation networked (direct connection) to another PC, will the COMMAND SYS(5) produce the DEFAULT directory of the workstation (where the
>FOXPRO executable resides) or the SERVER? I'm trying to create a situation
>where ONLY the SERVER can perform INDEXING of Tables.

SYS(5) only shows the current default directory. The problem is, it is common and often desirable to map network drive(s) on the server as well as the workstations to make running an app consistent.

For example, suppose a server named SERVER1 has a network share called FOXSHARE where the shared Fox data reside. The FOXSHARE share is actually a folder located somewhere on the server's physical C: drive. Suppose also we have a workstation named STATION1.

It's common practice to put commands in the network logon scripts so that everyone who needs to use the app gets a drive mapped to the data drive - something like this:
NET USE F: \\Server1\FoxShare
This is perfectly valid when run on the server console and will duly create a "network" drive F:. So the problem is, whether someone is running the app from a workstation or from the server console, they both see the data available on "drive F:".

One more reliable way to tell would be to see if the NetBIOS name of the machine hosting the shared data files is the same as the NetBIOS name of the machine currently running the executable.

Tracy Holzer provided some code in Re: How can i get the shared resource path my lpt1 is mapped Thread #683808 Message #683884 which can return the UNC name of a mapped resource. If we call this code the GetUNC() function, following our example above, GetUNC("F:") will return "\\Server1\FoxShare". From this we can parse out the server's NetBIOS name, "Server1".

SYS(0) returns the NetBIOS name of the computer where the executable is running. If the executable is running on STATION1 and the user is currently logged in as SomeUser, SYS(0) will return "STATION1 # SomeUser". From that we can parse out the NetBIOS name as "STATION1".

However, if it's being run on the server console, SYS(0) will return "SERVER1 # SomeUser".

So, if the machine name we get from SYS(0) is the same as the one we get from GetUNC(), we're running the program on the server. If not, we're running from a workstation.
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Previous
Reply
Map
View

Click here to load this message in the networking platform