Have a nice day!
Update: I think that i have all bug fixed
Code: Select all
#undef true
#undef false
const true = 1
const false = 0
Type ProtectedString
private:
protectetstringdata as string
readauthorized as byte
writeauthorized as byte
public:
Declare Operator Cast() As String
Declare Operator Let ( ByVal O as String )
'Auth
Declare Sub AuthorizeRead
Declare Sub AuthorizeWrite
'DeAuth
Declare Sub DeAuthorizeRead
Declare Sub DeAuthorizeWrite
End Type
Sub ProtectedString.DeAuthorizeWrite
writeauthorized = false
Print "DEBUG -> WRITE ACCESS DEAUTHORIZED"
end sub
Sub ProtectedString.DeAuthorizeRead
readauthorized = false
Print "DEBUG -> READ ACCESS DEAUTHORIZED"
end sub
Sub ProtectedString.AuthorizeWrite
writeauthorized = true
Print "DEBUG -> WRITE ACCESS AUTHORIZED"
end sub
Sub ProtectedString.AuthorizeRead
readauthorized = true
Print "DEBUG -> READ ACCESS AUTHORIZED"
end sub
Operator ProtectedString.cast () as string
if readauthorized = false then
Print "DEBUG READ -> READ ACCESS DENINED"
return ""
else
return protectetstringdata
end if
end operator
Operator ProtectedString.let ( ByVal O as String)
if writeauthorized = false then
Print "DEBUG WRITE -> WRITE ACCESS DENINED -> '"+o+"'"
else
protectetstringdata = o
end if
end operator
'Example
dim as protectedstring test
PRINT "This should not work because access is disabled by default"
test = "HI"
print test
PRINT "But when we enable access are all things possible :)"
test.authorizewrite
test.authorizeread
PRINT "But this should work"
test = "HELLO" + "MAIN"
print test
sleep
end