Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Replacement for USE/SELE table with IF...ELSE...ENDIF
Message
From
02/10/2007 09:25:47
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
02/10/2007 09:02:36
Jay Johengen
Altamahaw-Ossipee, North Carolina, United States
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
Miscellaneous
Thread ID:
01257862
Message ID:
01257874
Views:
15
>I know there is some way of putting this on one line using IIF (I think), but I just can't recall it right now. Thanks!
>
>
>IF !USED('Schedule')
>	USE Schedule IN 0
>ELSE
>	SELECT Schedule
>ENDIF
>
You might use a UDF. Here is mine:
FUNCTION SelectOrOpen(tcTableName, tcOrder, tcAlias, tnBuffering)
	* Abrir una tabla. Si ya estuviera abierto el alias, simplemente seleccionarlo.
	* Parámetros:
	* - tcTableName - la tabla que se quiere abrir
	* - tcOrder - el index tag que se ha de seleccionar
	* - tcAlias - con qué alias se quiere abrir la tabla
	* - tnBuffering - parámetro para buffering;
	*   normalmente igual a 5, 3, u omitido.
	if empty(tcAlias)
		tcAlias = tcTableName
	endif
	if used(tcAlias)
		select (tcAlias)
	else
		select 0
		use (tcTableName) alias (tcAlias) again
	endif
	if not empty(tcOrder)
		set order to (tcOrder)
	endif
	if VarType(tnBuffering) = "N"
		CursorSetProp("Buffering", tnBuffering)
	endif
ENDFUNC && SelectOrOpen
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Reply
Map
View

Click here to load this message in the networking platform