Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to save all SET settings?
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00947972
Message ID:
00948042
Views:
20
>Is there a command/function to save all SET settings, e.g. BELL, TALK, EXCLUSIVE, EXACT, etc. in an array/file? I would like save current settings, make changes and then restore settings while running a program.
>
>Thanks.

Try this PRG.
** When the procedure ends, the local variable is destroyed, triggering
** the Destroy event of the class
LOCAL oOdometer
oOdometer = CREATEOBJECT("SetCommand", "odometer to", "1000")


DEFINE CLASS SetCommand AS Custom

	** Define a hidden variable to hold the current setting
	HIDDEN sKeyWord
	HIDDEN vSaveSetting
	sKeyWord = ""
	vSaveSetting = NULL


	PROCEDURE Init(sSetCommand AS String, vNewValue AS Variant)
	
		LOCAL sKeyWord, sCommand

		WITH This
	
			** Remove spaces and covert to uppercase
			sSetCommand = UPPER(ALLTRIM(sSetCommand))
		
			** Remove the SET word, if it exists
			IF LEFT(sSetCommand, 3) = "SET"
				sSetCommand = ALLTRIM(STRTRAN(sSetCommand, "SET", ""))
			ENDIF
		
			** Get the keyword portion
			IF " " $ sSetCommand
				sKeyWord = SUBSTR(sSetCommand, 1, AT(" ",sSetCommand)-1)
			ELSE
				sKeyWord = ALLTRIM(sSetCommand)
			ENDIF

			** Save the keyword and the current setting
			.sKeyWord = sSetCommand
			.vSaveSetting  = SET(sKeyWord)
		
			** Reform the root of the command
			sCommand = "SET " + sKeyWord
			
			** Add the 'TO keyword, if needed
			IF " TO" $ sSetCommand
				sCommand = sCommand + " TO "
			ENDIF
			
			** Form the command string
			sCommand = sCommand + TRANSFORM(vNewValue)
			
			** Execute the string
			&sCommand
		
		ENDWITH
	
	ENDPROC

	PROCEDURE Destroy
	
		LOCAL sCommand
	
		WITH This
		
			sCommand = "SET " + .sKeyWord + " " + TRANSFORM(.vSaveSetting)
			&sCommand
			
		
		ENDWITH
	
	ENDPROC

ENDDEFINE
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Previous
Reply
Map
View

Click here to load this message in the networking platform