Complex Code Help Required

Discussion in 'Pascal Logic Code Examples' started by Trevor, Sep 17, 2024.

  1. Trevor

    Trevor

    Joined:
    Nov 22, 2018
    Messages:
    344
    Likes Received:
    26
    Location:
    Melbourne Victoria
    Hi All,
    I'm trying to build a test page on my workshop CTC touch screen.
    My basic goal is to have 10 buttons to select any 10 gate addresses save these values to 10 variables on the screen and then set the active text for those to the gate address.

    I'm using the user system io input to get the 10 values and display them on the buttons, this part works ok
    I then want to use the same numbers to set the group address for each of the buttons using the user system io number or even the text shown in the active text for the button. This is were im having problems, it keeps telling me i have a conflict in the data types. I have tried to convert the system io to something it can use but no luck. Has anyone tried anything like this before, i know its a bit out there... But wanted to do it so i can test any random set of 10 gate addresses to start with.

    Once i get over this hurdle i can the proceed to create the rest of the logic to loop through the selected addresses and do what ever whit them then.

    Some of the code i have so far...

    Initialisation section
    Gate_1 := '7'; {GetIntSystemIO(1); geen gives invalid data type }


    SetCompStringProp("Random Selection", "Gate_Status_1", "Text Inactive", Gate_1);

    Module section
    If ShowingPage("Random Selection") then
    if getlightingstate(250) = ON then
    Initialise all 10 addresses
    begin

    GetCompStringProp("Random Selection", "io_1", "Text Active", Gate_Status_1);

    gate_1 := GetCompIntegerProp("Random Selection", "io_1", "Gate_Status_1");

    Gate_1 := GetIntSystemIO(1);
    SetCompCBusProp("Main", "Scene", "Local", "Trigger", "My Scenes", "Relax Scene");
    char1 := chr(Gate_1);

    SetCompCBusProp("Random Selection", "Gate_Satus_1", "Workshop", "io_6",'C-Bus Group', io_1);
    SetCompCBusProp("Random Selection", "Gate_Satus_1", "Workshop", "Trigger", "My Scenes", 'io_1');
    WriteLn('Gate Address Number = ', char1);
    SetCompstringProp("Random Selection", "Gate_Satus_6", "Text Active", char6);

    end

    { SetCompStringProp("Main", "Lights", "Text Active", button_text_1);



    { for i := 1 to GetPageCompCount("Tools") do
    begin
    if GetCompType("Tools", i - 1) = 1 then // Only do this for button Components
    begin
    SetCompIntegerProp("Tools", i - 1, "Background Colour Active", clYellow);
    end;
    end; }

    regards
    Trevor
     
    Trevor, Sep 17, 2024
    #1
  2. Trevor

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,537
    Likes Received:
    177
    Location:
    Adelaide, Australia
    When you say Gate Address do you mean Group Address?

    I assume you have 10 buttons on the page. You want to interactively assign a group address to each button along with a level that will be set when you press the button? What control are you using to set the group address? Is there one for each button, or a single control for all buttons. If the later, how are you going to select which button? Then ditto for setting the group level.

    You logic seems to be confusing integers and character and strings

    on the line
    Gate_1 := '7'; {GetIntSystemIO(1); geen gives invalid data type }
    what is Gate_1 defined as? an integer? If so, you are trying to assign a character or string to it as you have enclosed the 7 in quotes. That's the invalid data type error.

    On
    SetCompStringProp("Random Selection", "Gate_Status_1", "Text Inactive", Gate_1)
    The last paramter must be a string (the text you want to send), but I assume Gate_1 is an integer. You would need to convert it to a string using the format() procedure.

    Here:
    GetCompStringProp("Random Selection", "io_1", "Text Active", Gate_Status_1);
    Gate_Status_1 needs to be a string to receive the current value of the "Text inactive" property
    but here:
    gate_1 := GetCompIntegerProp("Random Selection", "io_1", "Gate_Status_1");
    Gate_Staus_1 is a constant string which isn't the name of any valid property.

    It's all a bit of a mess :)(sorry)

    I think you need to back up a bit and start simpler. Create a single button and just try and change the text on it.

    If you can show me the page layout you are using I can prbably be more constructive. There are better ways of tackling this.
     
    Ashley, Sep 18, 2024
    #2
  3. Trevor

    Trevor

    Joined:
    Nov 22, 2018
    Messages:
    344
    Likes Received:
    26
    Location:
    Melbourne Victoria
    Hi Ashley
    Thanks for the reply,
    Yes it is a bit messy, but i have now sorted a lot of it out, i am using user system io to get the values for each button, then set the group address to the same number. This is all working now so i can get user input to set any of the 10 buttons. Now i just need to use an array to save the selected group addresses, then loop through them with code to act as the user needs.
    Your code from using arrays previously is perfect for that, so im in the middle now, putting together the user inputs into an array to loop through.
    A lot of the code you saw was very early experiments on getting and setting values,
    The hardest part was getting the system io and using this to make a group address, i was going about it all wrong at the start. Ill post an update next Tuesday when im back at work.
    The end result im after is to have 10 selectable group addresses thst can then be manipulated by the user selections...
    On, off, ramp, instant and loop counts
     
    Trevor, Sep 18, 2024
    #3
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.