Announcement

Collapse
No announcement yet.

Setting Field Property 'Visible' Dynamically

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Setting Field Property 'Visible' Dynamically

    Just was wondering if we had any code for setting the visible option dynamically in the field properties??
    For example if we want to see all the characters in a character field of 200 in length, we create one more text entry field in the screen layout and give the criteria ,that only if the length is greater than 90 characters(which is usually the number of characters that we could see on the screen without having to scroll) you display the extra text field that we created or else keep it invisible(or in other words setting the 'visible' property to 'no').

    I took a guess and wrote a code
    if length (_self_.text) > 90 then do;
    display1.visible() = 'Yes';
    _display1_.text=substr(_self_.text,91);
    end;

    where display1 is the text character field that i created on the screen layout. hope this is clear enough!!

    My clinplus is getting hung when i try and save this screen!

    thanks

  • #2
    Setting a fields visible property

    Yes you can set this, however, it is a property, not a method, so you would set it like this:

    fieldName.visible='No';
    fieldName.visible='Yes';

    Regards,

    Comment


    • #3
      Thanks Greg, the code works fine now.
      Greg i was just wondering if there is anything in the help that can tell us when to use a property and when to use a method!! What i mean is now the 'protected' is a property of the field, but according to the code that you gave me last to set the protected property to 'no', we used the method lock(), and for the visible property ,we set the property and did not use any method. my question is how will we know what to use and when to use it. Is their any list of methods???

      thanks.

      Comment


      • #4
        Some items such as the _lock() method are our methods which are not publicly documented. For a list of what we provide, please refer to the section Screen Code Overview.

        However, you do have access to the inherited properties from the object’s as provided by SAS. For a list of the objects and properties, please refer to the SAS Online doc at this location...

        http://support.sas.com/onlinedoc/913/docMainpage.jsp

        Note that there are some object properties that cannot be changed at run time and you will not be able to change.

        Regards,
        Last edited by Ronni Rubenstein; 04-01-2009, 10:37 AM.

        Comment


        • #5
          making fields visible/invisible

          I was trying to make text fields invisible depending on the entry of an object.

          if ethnic.object ne 'OTHER' then do;
          ethoth.visible='No'; ethoth_label.visible='No';
          height._goto();
          end;

          That code does not work. A very similar code:
          if age.text >30 then do;
          ethoth.visible='No'; ethoth_label.visible='No';
          height._goto();
          end;

          works perfectly for all ages >30. Is it possible to make fields invisible if the constraint (in this case a dropdown list) is an object type of field?

          Thanks, Thomas.

          Comment


          • #6
            Hi Thomas,

            In the case of a dropdown box, you would need to use the the SelectedItem or SelectedIndex attribute. SelectedItem will return the text of the selected item. SelectedIndex returns the indexed position of the selection.

            Try this...

            if ethnic.selectedItem ne 'OTHER' then do;
            ethoth.visible='No'; ethoth_label.visible='No';
            height._goto();
            end;


            Regards,
            Greg-
            Last edited by Ronni Rubenstein; 04-01-2009, 10:35 AM.

            Comment

            Working...
            X