1. IMPORTANT:
    We launched a new online community and this space is now closed. This community will be available as a read-only resources until further notice.
    JOIN US HERE

Using PGS with Tables

Discussion in 'Scripting Workshop' started by BMJ_FORUM, Nov 24, 2021.

  1. BMJ_FORUM

    BMJ_FORUM NI Product Owner

    Messages:
    38
    Hi all,

    HEADLINE: Shortly; How do you control TABLES specifically with PGS? I can do all other elements it seems, but this eludes me... Read more if you need context. Thanks in advance for any musings!

    I'm having a bit of a nightmare with attempting to control an element of the 'Poly Step' which is in the second slot, with the first slot being the main script handling everything else. I'm pulling the main elements of the Poly Step over to the GUI script so it can be controlled front end without tabs.

    I have sorted all the $ based controls like rate & mode etc... But I'm stuck with the % controls. Pitch and Velocity. I'm just getting an error, and I think it's a simple fix of just not using the command correct:

    Specifically in the 'on_ui' section of the GUI script. Example of one that works:

    on ui_control ($ps_mode)

    pgs_set_key_val(MODE, 0, $ps_mode)

    end on


    Now the same thing but I get an error (expected expression) when using in pitch for example:

    on ui_control (%PitchDisplay)

    pgs_set_key_val(PSPITCH, 0, %PitchDisplay)

    end on


    I get that it's likely a case of needing to switch out %PitchDisplay in the pgs line with a correctly written chunk of code, I just can't find anything on how to handle % tables with PGS... I tried to pull a while loop through from the second page and use that alongside the PGS, and I get no errors, but it doesn't act how it should. unsurprisingly... It currently just switches the pitch table somewhat randomly and not in line with the changes on the front page...:

    on ui_control (%PitchDisplay)

    $a := 0
    while($a < 16)
    pgs_set_key_val(PSPITCH, 0, %PitchDisplay[$a])
    inc($a)
    end while

    end on

    I'll continue to explore my own thoughts on how to do it, but if anyone here has the likely simple thing I'm missing, I'd love to hear it!
     
    Last edited: Nov 24, 2021
  2. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    You need to use the PGS key that is the same value as the table you want to transfer. You cannot use one single PGS index to cover the whole array (how does the other script know which exact table index you meant?).

    In fact, it is probably better to use a PGS key that is larger by one than the table you want to transfer. Then in the receiving script you act ONLY on value change in that very last index, and execute a loop to transfer the values (rather than looping on each table index change).