How to set Multiple Properties at Once Using Xbasic


Xbasic can be used to set one or more properties for multiple controls in a Grid or UX component. This is useful in certain situations, such as adding language tags to a large number of controls.


The Set Multiple Properties tool is great when you want to set multiple controls to the same property. If you wanted the property to be dynamically computed, however, you need to use Xbasic.

In the Set Multiple Properties dialog, you can check the Compute the property value using Xbasic code to expose an option that allows you to define an Xbasic function that calculates the new value for the selected property for each control. This is especially useful when you need to add language tags to the label for a large number of controls in your component. For example:

function setProperty as c (currentValue as a, arrI as p, wp as p)
    'currentValue is the value of the property in the control
    'arrI is a pointer to all properties in the control
    'wp is a pointer to all properties in the component

    'This sample will add language tags to a control's label if it does not already have language tags.

    dim newValue as c 'the value returned by this function must be a character value

    'check if the property already has language tags
    if atc("<a5:r>",currentValue) = 0 then
        newValue = "<a5:r>" + currentValue + "</a5:r>"
        newValue = currentValue
    end if

    'you can optionally prompt for confirmation before assigning the value to the control.
    'if you don't want to prompt, comment out this section
    dim q as n
    dim msg as c
    msg = "Assign value of " + newValue + " to control called: " + arrI.v.variableName
    q = ui_msg_box("Notice",msg,UI_FIRST_BUTTON_DEFAULT+UI_YES_NO_CANCEL)
    if q = ui_no_selected then
        newValue = currentValue
    end if
    'end of section to prompt for confirmation

    'the function returns newValue  - the value you want to assign to the property
    setProperty = newValue
end function

For complete step-by-step instructions, watch the videos below.