Normal Topic 'Switch' files (Read 540 times)
Rick_R
Full Member
***
Offline



Posts: 243
Joined: Jan 29th, 2010
'Switch' files
Apr 19th, 2011 at 5:12pm
Print Post Print Post  
Here is a technique I have used for a number of years on a variety of systems.  On a Sesame application I am developing I use it to create an "Admin Mode".  Currently, Admin Mode displays the command panel and non Admin Mode hides it.  Eventually I'll use it to allow adding new records.

Set a variable based simply on whether a particular file exists, e.g.,

stat sAdminMode as Boolean = False

If FileExists("c:\Sesame2\Admin.txt") then
{
     sAdminMode = True
     @MsgBox("","You are in Admin Mode.","")
}

The mere existence of a file entry -- even a zero-length file, changes the variable -- hence, the presence of the file acts as a "switch".

There are several advantages to this:

1) It doesn't require any changes to either the startup command parameters, any ini file, or any of the application code.

2) It is pretty easy to implement.

3) It pretty much makes hacking of the affected code impossible -- no unauthorized modifications to startup parameters, ini files, etc., will have any effect.

4) A true administrator can add or delete the switch files on any user's machine as needed (e.g., for troubleshooting) without changes that might cause some other problem.
  
Back to top
 
IP Logged
 
Steve_in_Texas
Senior Member
*****
Offline


No personal text

Posts: 893
Location: San Antonio
Joined: Feb 21st, 2004
Re: 'Switch' files
Reply #1 - Apr 20th, 2011 at 2:06am
Print Post Print Post  
Interesting concept. Thanks for sharing this.

Steve
  
Back to top
IP Logged
 
Rick_R
Full Member
***
Offline



Posts: 243
Joined: Jan 29th, 2010
Re: 'Switch' files
Reply #2 - Apr 20th, 2011 at 4:50am
Print Post Print Post  
As currently set up, global code in my Status form checks for Admin.txt.  Of course, that means other forms, etc., don't know about Admin Mode. (But users will mainly be using the Status form.)

For an application-wide switch the code should be in Application Program code and should set a ClientLocalValue("variable_name", value)
  
Back to top
 
IP Logged