Here is some code I wrote ages ago::
I used it in a button to set the web links on or off (bit #5), but there's no reason why the code cannot be altered to toggle any of the bits!
Mark.
Sub Click(Source As Button)
Dim PrefFile As String, BinPref As String, NewBinFile As String,newval As Double
Dim vNeg As Variant, dbPrefFile As Double, strpos As Integer
' Negative flag
vNeg = False
PrefFile = Sess.GetEnvironmentString( "Preferences", True )
dbPrefFile = Cdbl( PrefFile )
If dbPrefFile<0 Then
vNeg = True
dbPrefFile = 0 - dbPrefFile
End If
BinPref = Bin$( dbPrefFile )
strpos = Len( BinPref ) - 5
If Mid$( BinPref, strpos, 1 ) = "1" Then
Print "Adding Links.."
NewBinFile = Mid$( BinPref, 1 ,strpos-1) & "0" & Mid$( BinPref,strpos+1 )
Else
If Msgbox( "Are you sure - unset the web link hotspot?", 36,
"Confirm" ) = 6 Then
Print "Removing Links.."
NewBinFile = Mid$( BinPref, 1 ,strpos-1) & "1" & Mid$(BinPref, strpos+1 )
Else
Print "web hotspot link operation aborted.."
Exit Sub
End If
End If
newval = convbintoDBL( NewBinFile )
If vNeg Then newval = 0 - newval
Call Sess.SetEnvironmentVar( "Preferences", Cstr( newval ), True )
Print "web link operation completed... "
End Sub
Function convBinToDBL(strBin As String) As Double
Dim dTemp As Double , i As integer
dTemp = 0
For i = Len(strBin) To 1 Step -1
If Mid(strBin, i, 1) = "1" Then dTemp = dTemp + 2 ^ (Len(strBin)
- i)
Next i
convBinToDBL = dTemp
End Function