Generate a random number within a specific range

Hi all,
Is there a way to generate a random number within a specific range? For example, I want to generate a random number between 60 to 90. Can I able to do it using Appian functions? Using rand() function I can able to generate a random 2, 3, 4 .... digit numbers but not within a specific range.

OriginalPostID-257792

  Discussion posts and replies are publicly visible

Parents
  • Another work around
    load
    (
    local!min:50,
    local!max:100,
    local!occurance:10,
    local!arr1:Fixed(rand(local!occurance)*local!max,0),


    local!placesToChange:where(local!arr1<local!min),
    local!valuesToChange:index(local!arr1,local!placesToChange),
    local!differenceToAdd:local!min-index(local!arr1,local!placesToChange),
    local!updatedValues:local!min+local!valuesToChange,
    local!finalAnswer:updatearray(local!arr1,local!placesToChange,local!updatedValues),

    a!sectionLayout(
    label: "Lorem Ipsum",
    firstColumnContents: {
    a!textField(
    label: "minimum number",
    labelPosition: "ABOVE",
    value:local!min,
    saveInto: {},
    refreshAfter: "UNFOCUS",
    validations: {}
    ),
    a!textField(
    label: "maximumn number",
    labelPosition: "ABOVE",
    value:local!max,
    saveInto: {},
    refreshAfter: "UNFOCUS",
    validations: {}
    ),
    a!textField(
    label: "Occurance",
    labelPosition: "ABOVE",
    value: local!occurance,
    saveInto: {},
    refreshAfter: "UNFOCUS",
    validations: {}
    ),
    a!textField(
    label: "Original Random numbers",
    labelPosition: "ABOVE",
    value:local!arr1,
    saveInto: {},
    refreshAfter: "UNFOCUS",
    validations: {}
    ),
    a!textField(
    label: "places to change",
    labelPosition: "ABOVE",
    value:local!placesToChange,
    saveInto: {},
    refreshAfter: "UNFOCUS",
    validations: {}
    ),
    a!textField(
    label: "values to change",
    labelPosition: "ABOVE",
    value:local!valuesToChange,
    saveInto: {},
    refreshAfter: "UNFOCUS",
    validations: {}
    ),
    a!textField(
    label: "Difference To add",
    value:local!differenceToAdd,
    labelPosition: "ABOVE",
    saveInto: {},
    refreshAfter: "UNFOCUS",
    validations: {}
    ),
    a!textField(
    label: "Updated values",
    value:local!updatedValues,
    labelPosition: "ABOVE",
    saveInto: {},
    refreshAfter: "UNFOCUS",
    validations: {}
    ),
    a!textField(
    label: "Final answer",
    value:local!finalAnswer,
    labelPosition: "ABOVE",
    saveInto: {},
    refreshAfter: "UNFOCUS",
    validations: {}
    )
    },


    validations: {}
    )
    )


Reply
  • Another work around
    load
    (
    local!min:50,
    local!max:100,
    local!occurance:10,
    local!arr1:Fixed(rand(local!occurance)*local!max,0),


    local!placesToChange:where(local!arr1<local!min),
    local!valuesToChange:index(local!arr1,local!placesToChange),
    local!differenceToAdd:local!min-index(local!arr1,local!placesToChange),
    local!updatedValues:local!min+local!valuesToChange,
    local!finalAnswer:updatearray(local!arr1,local!placesToChange,local!updatedValues),

    a!sectionLayout(
    label: "Lorem Ipsum",
    firstColumnContents: {
    a!textField(
    label: "minimum number",
    labelPosition: "ABOVE",
    value:local!min,
    saveInto: {},
    refreshAfter: "UNFOCUS",
    validations: {}
    ),
    a!textField(
    label: "maximumn number",
    labelPosition: "ABOVE",
    value:local!max,
    saveInto: {},
    refreshAfter: "UNFOCUS",
    validations: {}
    ),
    a!textField(
    label: "Occurance",
    labelPosition: "ABOVE",
    value: local!occurance,
    saveInto: {},
    refreshAfter: "UNFOCUS",
    validations: {}
    ),
    a!textField(
    label: "Original Random numbers",
    labelPosition: "ABOVE",
    value:local!arr1,
    saveInto: {},
    refreshAfter: "UNFOCUS",
    validations: {}
    ),
    a!textField(
    label: "places to change",
    labelPosition: "ABOVE",
    value:local!placesToChange,
    saveInto: {},
    refreshAfter: "UNFOCUS",
    validations: {}
    ),
    a!textField(
    label: "values to change",
    labelPosition: "ABOVE",
    value:local!valuesToChange,
    saveInto: {},
    refreshAfter: "UNFOCUS",
    validations: {}
    ),
    a!textField(
    label: "Difference To add",
    value:local!differenceToAdd,
    labelPosition: "ABOVE",
    saveInto: {},
    refreshAfter: "UNFOCUS",
    validations: {}
    ),
    a!textField(
    label: "Updated values",
    value:local!updatedValues,
    labelPosition: "ABOVE",
    saveInto: {},
    refreshAfter: "UNFOCUS",
    validations: {}
    ),
    a!textField(
    label: "Final answer",
    value:local!finalAnswer,
    labelPosition: "ABOVE",
    saveInto: {},
    refreshAfter: "UNFOCUS",
    validations: {}
    )
    },


    validations: {}
    )
    )


Children
No Data