Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8654689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:50:57+00:00 2026-06-12T14:50:57+00:00

In C# this is allowed: [Flags] private enum PermissionType { Read = 0x0001, Write

  • 0

In C# this is allowed:

    [Flags]
    private enum PermissionType
    {
        Read = 0x0001,
        Write = 0x0002,
        Execute = 0x0004,
        All = Read | Write | Execute
    }

This allows:

private bool TestPerm(PermissionType p)
{
    if( PermissionType.Read & p) return true; // user can read    
    if( PermissionType.Write & p) return true; // user can write
    if( PermissionType.Execute & p) return true; // user can Execute
    //etc
}

It can be called like this:

Testperm( PermissionType.Read | PermissionType.Write ); 

I know there is no enum DataType in ObjectScript, but I think a regular class with properties like this should work…

Class Sample.AcknowledgeType Extends %RegisteredObject
{
    Property Read As %Integer [ InitialExpression = 1 ];
    Property Write As %Integer [ InitialExpression = 2 ];
    Property Execute As %Integer [ InitialExpression = 4 ];
    Property All As %Integer [ InitialExpression = 7 ];
}

This is as far as I got. How do I write the TestPerm method?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T14:50:58+00:00Added an answer on June 12, 2026 at 2:50 pm

    It doesn’t work like that.

    Each property you define on the object uses a field in memory (and on disk if it is a persistent class) for each instance. So rather than defining a property with an initial expression, you would probably define a class parameter for read, write, execute, and all.

    Also, the MUMPS language that Cache Object Script is a superset of doesn’t let you do bit twiddling. There is an extension to the language that does allow this – the $BIT built-in function. This gets/sets the value of a bitstring at the specified location in the string.

    Therefore, you could try:

    Parameter READ=1;
    Parameter WRITE=2;
    Parameter EXECUTE=3;
    
        Method TestPerm(Permissions as %String) as %Boolean
        {
            If $BIT(Permissions,..#READ) Quit 1
            If $BIT(Permissions,..#WRITE) Quit 1
            If $BIT(Permissions,..#EXECUTE) Quit 1
            Quit 0
        }
    

    Without bitwise Boolean operators this isn’t that handy. It gets worse.

    You can’t actually access the class parameters from outside the class without using the reflection capabilities in the %Dictionary package. That’s too hard and too slow, so probably the best available choice is to expose the enumeration values with methods.

    Method GetReadParameter()
    {
        Quit ..#READ
    }
    

    So now it’s possible to write:

    Set $BIT(Permissions,MyObject.GetReadParameter())
    Set $BIT(Permissions,MyObject.GetWriteParameter())
    Set HasPermission=MyObject.TestPerm(Permissions)
    

    So, once we’re done admiring the beauty of that code, it’s probably time to admit that without native bitwise Boolean operators this C# idiom just isn’t worth it. Instead just make a Permissions class, with Boolean properties Read,Write, and Execute. “All” can be a computed property.

    If you really want you can make a Permissions class that has Read, Write, Execute, and All, each of which is Boolean and computed. You can write getter and setter methods that access a private property and use $BIT to set and read the value. But your Boolean logic would happen with the returned values, so rather than

    Testperm( PermissionType.Read | PermissionType.Write ); 
    

    you would do

    If (myPermissions.Read || myPermissions.Write)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I hope this is allowed but I have a number of questions regarding Facebook
This is not allowed in Mysql: SELECT CAST(0 as DOUBLE) as ZERO How do
I have followed this tutorial which allowed me to create a Silverlight DataGrid that
I want to create a model named Model. I'm pretty sure this isn't allowed,
This should really be allowed - I do not understand why it is not.
This may seem pretty basic, are you allowed to put a link inside of
This code checks for dead links. Since 3rd party Ajax requests are not allowed
I have this little NetStream movie (which I'm not allowed to show, sorry) set
I am implementing this hoemwork functionality using Ocaml: Not allowed to use List module
I need to rewrite this query and I'm not allowed to use a subquery.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.