Has anyone used the Array's in Piced logic.

Discussion in 'Pascal Logic Code Examples' started by Trevor, Jul 7, 2022.

  1. Trevor

    Trevor

    Joined:
    Nov 22, 2018
    Messages:
    235
    Likes Received:
    16
    Location:
    Melbourne Victoria
    Hi All I'm trying to create a list of gate address's that i can select a gate address from to test, excluding ones that i have allocated to controlling my test page actions.

    I'd like to be able to use a slider control to select only the available gate address's not used for my program control. At the moment it will range between 0 and 255.

    Is this possible, or is there another way to accomplish the same task.
    So far i have tried to use an Array to hole the available gate address's to test but can't get that to work. Does anyone have examples of using arrays they'd like to share?

    regards
    Trevor
     
    Trevor, Jul 7, 2022
    #1
    1. Advertisements

  2. Trevor

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,423
    Likes Received:
    160
    Location:
    Adelaide, Australia
    What are "gate addresses" ?

    Can you post your current code?
     
    Ashley, Jul 7, 2022
    #2
    1. Advertisements

  3. Trevor

    Trevor

    Joined:
    Nov 22, 2018
    Messages:
    235
    Likes Received:
    16
    Location:
    Melbourne Victoria
    Off work until next Tuesday, ill post a part of the project with that page. The other thing im trying to do is monitor a slider that changes a user system io, trying to get it to change color if its on a bad gate address.

    Thanks for the quick reply much appreciated.
    Regards Trevor
     
    Trevor, Jul 7, 2022
    #3
  4. Trevor

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,423
    Likes Received:
    160
    Location:
    Adelaide, Australia
    So what exactly is a gate address?
     
    Ashley, Jul 7, 2022
    #4
  5. Trevor

    Trevor

    Joined:
    Nov 22, 2018
    Messages:
    235
    Likes Received:
    16
    Location:
    Melbourne Victoria
    :D
    You know something that can be turned on off, dimmed.

    P.S. i ment groupo_O
     
    Trevor, Jul 7, 2022
    #5
  6. Trevor

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,423
    Likes Received:
    160
    Location:
    Adelaide, Australia
    This should get you going.

    Add a slider to a page, set it's range from 0 to 255 and give it the name 'slider' (under the general tab)

    Code:
    // Global variables section
    sliderArray: array[0..255] of boolean; // Define array. Will be set True for  valid group, false otherwise
    sliderValue: integer; // Temp value to read slider
    i: integer; // For loop counter
    
    // Initialization section
    for i := 0 to 255 do sliderArray[i] := true; // Assume most are valid (I assume this is true?)
    sliderArray[9] := false;  // Add a few random invalid addresses. Change as required
    sliderArray[21] := false;
    sliderArray[45] := false;
    sliderArray[46] := false;
    sliderArray[47] := false;
    sliderArray[48] := false;
    sliderArray[49] := false;
    sliderArray[110] := false;
    sliderArray[111] := false;
    sliderArray[112] := false;
    
    // Module
    sliderValue :=  GetIntSystemIO("SliderValue"); //Read slider position
    if hasChanged(sliderValue) then // Wait till someone moves slider
    begin
      if sliderArray[sliderValue] then // Check if  valid group
        SetCompIntegerProp("Page 1", "Slider", "Slider Slot Background Colour", clWhite) // Valid, set slider slot white
      else
        SetCompIntegerProp("Page 1", "Slider", "Slider Slot Background Colour", clRed); // Invalid, set slider slot red
    end;
    This just changes the colour of the slider slot. You can change any attribute you want. Easiest way is to right click in the logic and select Page/Comp Properties then Set Comp Prop.
     
    Ashley, Jul 10, 2022
    #6
  7. Trevor

    Trevor

    Joined:
    Nov 22, 2018
    Messages:
    235
    Likes Received:
    16
    Location:
    Melbourne Victoria
    Hi Ash,
    Thats frigin amazing, perfect for setting the slider color, and perhaps i can adapt it in sone way to limit availabe address displayed.
    You are truly amazing man.

    Regards
    Trevor
     
    Trevor, Jul 10, 2022
    #7
  8. Trevor

    Trevor

    Joined:
    Nov 22, 2018
    Messages:
    235
    Likes Received:
    16
    Location:
    Melbourne Victoria
    Hi All, and Ash,
    Here's my sample project so far, it does still have some bugs to get out but the overall functionality is working OK.
    You can select between relay or dimmer, 1, 4, 8 or 12 channels to test, the lower section lets you select all dimmer or relay options. This is also were you select a specific group address to test if required. Some addresses are blanked out as they are used for project control. And thanks to Ash i was able to add hiding the project addresses as well as turning the slider red until an allowed group is selected.

    Just a fun little project to learn more about logic, hope people out there can also use it. Let me know and i can provide updates when the whole thing is completed.

    regards
    Trevor
     

    Attached Files:

    Trevor, Jul 11, 2022
    #8
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.