Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
IF USED()=.F. OPEN else SELECT the Table (Foxpro 2.5b)
Message
From
04/03/2000 14:28:56
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
FoxPro 2.x
Miscellaneous
Thread ID:
00341636
Message ID:
00341710
Views:
27
>I am using a quite simple and very usefull routine for years that works great if the table is in the same directory as the program but refuse to work if the table is in a different directory.
>
>Well.. I could probably figure it out if I take the time to do it but there are probably many of you that has the routine already made and working perfectly. So why reinvent the weel?
>
>The procedure check the following: if the table is not opened, it opens it and select it. If it is opened it onky select it. The second parameter is to select the order tag.
>
>* FICHIER.PRG (Foxpro 2.5b)
>*-----------------------------
>PARAMETERS _DBF,ORDRE
>IF USED(_DBF)=.F.
>   USE (_DBF) IN 0
>ENDIF
>SELECT (ALIAS(_DBF))
>IF PARAMETERS()=2
>   SET ORDER TO (ORDRE)
>ENDIF
>
>So... how can it also work with tables in different directories than the program.
>
>Thanks in advance.


There are many ways to do :) As I understand you use either fullpath or just filename as _DBF. Used() checks for alias not fullpath so if it's in another dir (fullpath supplied) it fails. If you don't need a very robust version (e.g. taking into consideration that a table could be opened multipl times all with different alias names other than filename, filenames are not LFN etc) then this one works :
function myUse
parameters tcTable, tcOrder
lcAlias = strtran( ;
     iif(at("\",tcTable)>0, ;
        substr(tcTable,rat("\",tcTable)+1), ;
        tcTable), ;
     ".dbf","")     && Strip just alias
if !used(lcAlias)
	use (tcTable) in 0 && Fox automatically assigns filename as alias
endif
select (lcAlias)
if parameters()=2
   set order to tag ;
      (iif(type("tcOrder") = "N", ;
      tag(tcOrder), tcOrder)) 
      && If tcOrder is numeric get tagname else use tcOrder
endif
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform