Script Warning: control ID was not declared

Discussion in 'Scripting Workshop' started by CK_S, May 21, 2019.

  1. CK_S

    CK_S NI Product Owner

    Messages:
    32
    I realized that I get this warning because of on persistence changed command at the end of my scripts.

    I used it for having default displayed values on some labels when the script is loaded.

    everything works with no problem or script errors...

    when i remove this part from the script the warning disappears.


    Code:
    on persistence_changed
    set_control_par_str(get_ui_id($LABEL_1b),$CONTROL_PAR_TEXT,"VOLUME:")
    set_control_par_str ($cur_slider,$CONTROL_PAR_LABEL,...
        get_engine_par_disp($ENGINE_PAR_VOLUME,1,0,-1) & " dB")
        set_text ($LABEL_1c,get_engine_par_disp($ENGINE_PAR_VOLUME,1,0,-1) & " dB")
    
    set_control_par_str(get_ui_id($LABEL_2b),$CONTROL_PAR_TEXT,"VOLUME:")
    set_control_par_str ($cur_slider,$CONTROL_PAR_LABEL,...
        get_engine_par_disp($ENGINE_PAR_VOLUME,11,0,-1) & " dB")
        set_text ($LABEL_2c,get_engine_par_disp($ENGINE_PAR_VOLUME,11,0,-1) & " dB")
    end on
     
  2. EvilDragon

    EvilDragon Moderator Moderator

    Messages:
    14,599
    It's because you're using $cur_slider variable instead of getting UI ID directly. It might not be a valid UI ID, that's why you get the warning.
     
  3. CK_S

    CK_S NI Product Owner

    Messages:
    32
    $cur_slider is a valid ui id.
    i replaced these variables with the actual ui control names but unfortunately the problem exists.

    I mean the warning is not inside the script but on kontakt Gui instead.

    id war.PNG
     
  4. EvilDragon

    EvilDragon Moderator Moderator

    Messages:
    14,599
    Yes, that's how warnings show up. So which value is in $cur_slider, and where are you setting it?

    I bet if you comment out those lines that contain $cur_slider in persistence_changed, that the warning will not show, which means that whatever value is stored in $cur_slider, is not a valid UI ID :)
     
  5. CK_S

    CK_S NI Product Owner

    Messages:
    32
    good thinking but $cur_slider has a different value in each ui_control.I used that some months ago in 2-3 scripts to help me copy-paste some lines and not to replace ui_control names inside the commands.maybe it wasnt so efficient as it seems now...
    I used $cur_slider variable in most ui controls, such as volume, filter cutoff, attack etc.
     
  6. EvilDragon

    EvilDragon Moderator Moderator

    Messages:
    14,599
    Yes, so obviously it makes no sense to use it in persistence_changed then if it's a variable that changes its value depending on which control you clicked on...

    I'm just going by your code literally. You have two lines that refer to $cur_slider but a different label is printed out to them, and there's no place where you change $cur_slider's value...

    So again I ask - what happens when you comment out the lines from persistence_changed that contain $cur_slider? Do you get a warning then or not?
     
  7. CK_S

    CK_S NI Product Owner

    Messages:
    32
    I replaced the $cur_slider inside the persistence changed callback, with the actual ui_control names but I still get the warning

    Maybe ishould try to remove completely the variable and use the actual ui control names.
     
    Last edited by a moderator: May 21, 2019
  8. EvilDragon

    EvilDragon Moderator Moderator

    Messages:
    14,599
    Did you just use UI control names, or did you also get_ui_id(control name)?
     
  9. CK_S

    CK_S NI Product Owner

    Messages:
    32
    ui_control names only.the same code I used inside each ui_control

    I tried to use the real control names instead of a custom variable but I still get the warning.

    example:

    Code:
    on ui_control ($slider2791241)                          {REVERB LEVEL}
    
    set_engine_par($ENGINE_PAR_SENDLEVEL_0,$slider2791241,-1,7,1)
    
    set_control_par_str(get_ui_id($REV_LAB_2),$CONTROL_PAR_TEXT,"LEVEL:")
    set_control_par_str ($slider2791241,$CONTROL_PAR_LABEL,...
        get_engine_par_disp($ENGINE_PAR_SENDLEVEL_0,-1,7,1))
        set_text ($REV_LAB_3,get_engine_par_disp($ENGINE_PAR_SENDLEVEL_0,-1,7,1)& " dB")
     
    end on
    
    on persistence_changed
    
    set_control_par_str(get_ui_id($REV_LAB_2),$CONTROL_PAR_TEXT,"LEVEL:")
    set_control_par_str ($slider2791241,$CONTROL_PAR_LABEL,...
        get_engine_par_disp($ENGINE_PAR_SENDLEVEL_0,-1,7,1))
        set_text ($REV_LAB_3,get_engine_par_disp($ENGINE_PAR_SENDLEVEL_0,-1,7,1)& " dB")
    
    end on
     
  10. EvilDragon

    EvilDragon Moderator Moderator

    Messages:
    14,599
    Yes that won't work. Whenever you use get/set_control_par commands, you need to use valid UI IDs. Just using the names of controls will not work because they are not UI IDs, they are the actual value of the control. So, you're missing get_ui_id() in this case - both in your UI callback and in persistence_changed.

    You do it correctly for the text label, but not for the slider control. Bizarre :)
     
  11. CK_S

    CK_S NI Product Owner

    Messages:
    32
    yes that solve the issue!
    thanks again!
    :thumbsup: