Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is table already open under diff alias?
Message
 
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01448039
Message ID:
01448223
Views:
36
>>To check if the certain table is opened in the particular DS you need to use aUsed() function.
>>
>>I'm missing something... why not just the USED() function? The only problem I see is if the table could have some other alias, meaning USED() and aUSED() won't spot it.
>>
>>
>>USE mytable ALIAS someother
>>? USED('mytable') &&returns .F.
>>=aUSED(aTables)
>>? aTables(1,1) &&returns SOMEOTHER, not mytable
>>
>>
>>Then you'd need to use the DBF() function to iterate through looking for an alias with the correct underlying table. Seems like a lot of work.
>>
>>How about
>>
>>
>>Local llMyAliasOpen
>>Select 0
>>llMyAliasOpen=.F.
>>Try
>>	Use mytable Again Alias myalias
>>Catch
>>	*---myalias is open now one way or another...
>>	*---flag this so it doesn't get closed at end of routine
>>	llMyAliasOpen=.T.
>>Finally
>>
>>
>>You have to use ALIAS or it will reopen the table with A, B. C... aliases. You can open it ALIAS mytable if you want to use the tablename. It would be much more complex if you want to use any existing alias for that table that may happen to be open, but that's time for a redesign IMHO.
>
>I think we're drifting from the original problem. The original problem was to check if the particular table is opened under any alias. Your code (without again) will work, e.g.
>
>Local llMyTableOpened
>
>>llMyTableOpen=.F.
>>Try
>>	Use mytable Alias UsedJustToCheck  in 0 shared
>>Catch
>>	*---myalias is open now one way or another...
>>	*---flag this so it doesn't get closed at end of routine
>>	llMyTableOpen=.T.
>>Finally
>   use in select('UsedJustToCheck')
I think what John was saying makes sense. It looks like my problem could be solved much simpler. I just need to open/use the table under some alias with the word AGAIN. And then close this temporary alias. This way, if the table is opened prior to this procedure it stays open; if it was not opened, it will be closed after. Do you see what I mean?
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform