Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Replacement for USE/SELE table with IF...ELSE...ENDIF
Message
De
02/10/2007 13:35:08
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
 
À
02/10/2007 12:39:11
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 8 SP1
Divers
Thread ID:
01257862
Message ID:
01258000
Vues:
17
>I refer to the one-liner:
>
>
Use schedule in select('schedule')
>
>(I have the feeling I've seen your promulgating this technique in the past - or it was something very similar)
>
>and my saying:
>
>"Now I've just tried this one
>
>Use schedule in select('schedule')
>with 2 tables open:
>
>If SCHEDULE is not open then it's opened and selected - fine.
>However, if the other table is selected, then SCHEDULE does not get selected, the other table stays selected."

Let's thread.root.goto():
IF !USED('Schedule')
	USE Schedule IN 0
ELSE
	SELECT Schedule
ENDIF
This code doesn't select the alias either - if not used, it will open it somewhere, but won't select it. Five lines.
Then we had a better version:
IF !USED('Schedule')
	USE Schedule IN 0
ENDIF
SELECT Schedule
Which selects it, four lines. The one-liner we talked about replaces the first three lines - and does nothing (as USE... IN... never did that) to change current workarea.
select TableA
use tableB in 0
use tableC in 0
You wouldn't expect tableC to be selected after this, would you? Because you told it to open elsewhere.

In the end we have
USE Schedule IN select('Schedule')
SELECT Schedule
- two lines to do two things. Mind you, you don't necessarily want to select every table that you open - it may be sought() (seek()ed?) or related into or selected FROM or referenced in any other manner, depending on what you need it for. I, for one, wouldn't like the USE statement to always select the table it opens.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform