Order check of 10 variables

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #202784 quote
    robdav
    Participant
    Veteran

    Hi

    I have ten variables and I need to check they are in order.

    See below:

    var1 = 1 // boolean
    var2 = 1 // boolean
    var3 = 1 // boolean
    var4 = 1 // boolean
    var5 = 1 // boolean
    var6 = 1 // boolean
    var7 = 1 // boolean
    var8 = 1 // boolean
    var9 = 1 // boolean
    var10 = 1 // boolean
    
    if (var1 >= var2) and (var2 >= var3) and (var3 >= var4) and (var4 >= var5) and (var5 >= var6) and (var6 >= var7) and (var7 >= var8) and (var8 >= var9) and (var9 >= var10) then
       inorder = 1
    else
       inorder = 0
    endif

    The problem I’m having is the variables can be enabled or disabled by the user. If they are disabled, then their value is 0.

    Therefore, using the above test fails if any one of them isn’t enabled.

    Other than a convoluted bunch of if/ then statements, is there another way to achieve such a check?

    Thanks

    Rob

    #202810 quote
    robertogozzi
    Moderator
    Master

    Can you make an  example of the value they may retain and which is the  order you need?

    #202813 quote
    robdav
    Participant
    Veteran

    Hi Roberto

    The values could be anywhere in the range say 1-2000.

    If the variable values are in order (depending on which are enabled) then they are not interesting. In order is as mentioned in first post so (var1 >= var2) and (var2 >= var3) etc.

    So if any of the lower ones are enabled they should always be a higher number than the higher ones.

    Sometimes they get completely out of order and it would be useful to know those orders without having to check manually but I think that is too complicated. Simply knowing when they are not in the primary order would be a start.

    I hope that makes sense? Let me know if not.

    Many thanks

    Rob

    #202837 quote
    robertogozzi
    Moderator
    Master

    You need to use arrays, instead of variables.

    You will find useful info at https://www.prorealcode.com/topic/array-variables-availability-in-prorealtime/.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

Order check of 10 variables


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
robdav @robdav Participant
Summary

This topic contains 3 replies,
has 2 voices, and was last updated by robertogozzi
3 years, 3 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 10/18/2022
Status: Active
Attachments: No files
Logo Logo
Loading...