Using a static Ass value in the Privilege Level value of a component?

I have opened a parameterised popup, preceding the WinNewAt function with:

```

Ass(-2, "DeviceName", sDeviceName, 0)
Ass(-2, "Privilege", iPrivilege, 0)

WinNewAt(sPopupName, 10, 10, 1 + 4 + 256 + 512)

```

I want to use the iPrivilege value as the Privilege Level of a component, but I'm getting a "Bad integer value" error...

How would I do this?

Parents
  • I solved this by ignoring the Privilege Level and setting the Disable condition to `NOT GetPriv(?Privilege?, 0)` because clearly that makes sense.

    However, I have a similar issue, where I can't use this when passing ?Privilege? into a Genie's params and using the same GetPriv function inside the genie components??

    In the runtime I see the dot matrix overlay and there are no privilege restrictions... I wish I knew what the error was that the dots are telling me...

Reply
  • I solved this by ignoring the Privilege Level and setting the Disable condition to `NOT GetPriv(?Privilege?, 0)` because clearly that makes sense.

    However, I have a similar issue, where I can't use this when passing ?Privilege? into a Genie's params and using the same GetPriv function inside the genie components??

    In the runtime I see the dot matrix overlay and there are no privilege restrictions... I wish I knew what the error was that the dots are telling me...

Children
  • In a graphic object, the Privilege field expects a literal value, like 8, not an expression. If you use a genie substitution, like %Privilege%, that works because the graphics builder replaces that with the literal value that you substitute in, so it still sees a literal value in the runtime. However, Super Genie (or 'dynamic') associations act more like a variable. So, if you use ?Privilege? it acts like a variable containing the value, which is not allowed and caused the 'Bad integer value' compile error.

    However, the Disable when field does expect an expression, and is the proper way do do what you want using a super genie association like ?Privilege?. I'm not clear why that isn't working. I suggest you add a numeric display to the genie with the expression %Privilege%. That should be substituted with the the value you entered, ?Privilege?, which should be equal to the value you associated with the page when it is opened in the runtime. You could also create a numeric object to display ?Privilege?. That way you can verify that the substitution and association are working correctly.

  • To assign a constant you have to put the value between single quotes:

    Ass(-2, "DeviceName", "'" + sDeviceName + "'", 0);
    Ass(-2, "Privilege", "'" + IntToStr(iPrivilege) + "'", 0);

    And if it still not works as expected, you might want to make sure the object treats the assignment as an integer by using:

    ?INT Privilege? instead of ?Privilege?

    Also, the word "privilege" and/or "priv" might be reserved words, so you could try using something else.