Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Want a 1 char code read into my app
Message
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00490001
Message ID:
00490008
Vues:
9
>Want to have the ability to turn on and off a feature. What is an easy way to have a 1 char code read into my MAIN to use int an IF statement. I have a config.fpw, could i use that?
>
>Thanks
>
>Brenda

Sure you can add your own Items to config.fpw because foxpro will ignore any lines with unknown keywords.

For example,

Myflag=YES

I included a function that I wrote awhile ago that lets you get value for specified Item.

lcVal = GetCfgItem("Myflag") will return 'YES' if you have Myflag=YES in config.fpw
FUNCTION GetCfgItem
PARAMETER tcItemName, tcCfgFileName
LOCAL lnCfgHandle, lnItemNameLen, lcRetVal, lcCfgFileName, lcItemName, lcBuffer
IF TYPE("tcCfgFileName") <> "C" OR EMPTY(tcCfgFileName)
	* FoxPro Configuration file
	lcCfgFileName = SYS( 2019 )
ELSE
	lcCfgFileName = ALLTRIM(tcCfgFileName )
ENDIF	
lcItemName = UPPER( ALLTRIM( tcItemName  ) )
lnItemNameLen = LEN(lcItemName)
lnCfgHandle = FOPEN( lcCfgFileName )
IF lnCfgHandle < 1
	WAIT WINDOW "Could not open Configuration file " + lcCfgFileName + ". Any key..."
	RETURN ""
ENDIF
lcRetVal = ""
DO WHILE NOT FEOF( lnCfgHandle )
	lcBuffer = UPPER( ALLTRIM( FGETS( lnCfgHandle ) ) )

	IF LEFT( lcBuffer, lnItemNameLen ) == LEFT(lcItemName, lnItemNameLen)
		lcRetVal = ALLTRIM(RIGHT( lcBuffer, LEN( lcBuffer ) - AT( "=", lcBuffer ) ))
		EXIT
	ENDIF
ENDDO
=FCLOSE( lnCfgHandle )
RETURN lcRetVal
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform