String problem

Home Forums General Programming String problem

Viewing 16 posts - 1 through 16 (of 16 total)
  • Author
    Posts
  • #23849
    zeoka
    Participant
    • Topics: 73
    • Replies: 466
    • Total: 539
    • ★★★

    What’s wrong here?

    -- Called when a modulator value changes
    -- @mod   http://ctrlr.org/api/class_ctrlr_modulator.html
    -- @value    new numeric value of the modulator
    --
    label = function(mod, value)
    updlbl = panel:getComponent("TrigSel")
    lb1 = panel:getComponent("01SoundLabel"):getComponentText()
    lb2 = panel:getComponent("02SoundLabel"):getComponentText()
    lb3 = panel:getComponent("03SoundLabel"):getComponentText()
    lb4 = panel:getComponent("04SoundLabel"):getComponentText()
    --updlbl:setProperty("uiListBoxContent",string.format("%s \n %s \n %s \n %s",lb1,lb2,lb3,lb4),false) 
    -- string expected , got user data 
    panel:getComponent("modulator-5"):setText(lb1)
    panel:getComponent("modulator-7"):setText(lb2)
    panel:getComponent("modulator-8"):setText(lb3)
    panel:getComponent("modulator-9"):setText(lb4)
    -- the components texts are displayed correctly in four texts
    end

    it seems setText get lb1 as text format with “” or convert user data in string .that’s working but string.format get it as user data I don’t know
    why. I tried to quote lb1 with string.format and %q ,tried string.sub too.
    I search on google but no success

    This is a listbox that get current rows selected of four other listboxes
    I would try to do.the script is applied to the four mods.

    any idea ??

    #23850
    dasfaker
    Keymaster
    • Topics: 80
    • Replies: 793
    • Total: 873
    • ★★★

    –updlbl:setProperty(“uiListBoxContent”,string.format(“%s \n %s \n %s \n %s”,lb1,lb2,lb3,lb4),false)

    Try this (not tested)

    updlbl:setPropertyString(“uiListBoxContent”,string.format(“%s \n %s \n %s \n %s”,lb1,lb2,lb3,lb4),false)

    #23857
    zeoka
    Participant
    • Topics: 73
    • Replies: 466
    • Total: 539
    • ★★★

    I ve already tried
    Could i try different way to “mix” these strings or not and put them in
    the listbox ?

    #23867
    zeoka
    Participant
    • Topics: 73
    • Replies: 466
    • Total: 539
    • ★★★

    the console returns string however

    Attachments:
    You must be logged in to view attached files.
    #23874
    dasfaker
    Keymaster
    • Topics: 80
    • Replies: 793
    • Total: 873
    • ★★★

    Remove “false” at the end.

    This line is working for me

    list1:getComponent():setPropertyString("uiListBoxContent",
    string.format("%s%s%s",text12,"\n",text11))
    • This reply was modified 8 years, 1 month ago by dasfaker.
    #23877
    zeoka
    Participant
    • Topics: 73
    • Replies: 466
    • Total: 539
    • ★★★

    Yes I did removed the bool
    not tried to format the separators… done
    but there is still the bad argument #2

    may be the result is in char index and setText converts it to string
    while PropertyString not… strange
    or the result lacks “” and setText add it

    updlbl:setPropertyString(“uiListBoxContent”,lb1)
    WORKING
    updlbl:setProperty(“uiListBoxContent”,lb1,false)
    NOT WORKING

    but the mix isn’t working
    updlbl:setPropertyString(“uiListBoxContent”,string.format(“%s%s%s%s%s%s%s”,lb1,”\n”,lb2,”\n”,lb3,”\n”,lb4))
    tried this :
    updlbl:getSelectedRow(1):setPropertyString(“uiListBoxContent”,lb1)
    updlbl:getSelectedRow(2):setPropertyString(“uiListBoxContent”,lb2)

    attempt to index a number value…
    selectRow() ??

    #23878
    zeoka
    Participant
    • Topics: 73
    • Replies: 466
    • Total: 539
    • ★★★

    even if I do :

    
    updlbl = panel:getComponent("TrigSel")
    lb1 = panel:getComponent("01SoundLabel"):getComponentText()
    panel:getComponent("modulator-5"):setText(lb1)
    console(lb1)
    lb2 = panel:getComponent("02SoundLabel"):getComponentText()
    panel:getComponent("modulator-7"):setText(lb2)
    console(lb2)
    lb3 = panel:getComponent("03SoundLabel"):getComponentText()
    panel:getComponent("modulator-8"):setText(lb3)
    console(lb3)
    lb4 = panel:getComponent("04SoundLabel"):getComponentText()
    panel:getComponent("modulator-9"):setText(lb4)
    console(lb4)
    z1 = panel:getComponent("modulator-5"):getText()
    z2 = panel:getComponent("modulator-7"):getText()
    z3 = panel:getComponent("modulator-8"):getText()
    z4 = panel:getComponent("modulator-9"):getText()
    updlbl:setPropertyString("uiListBoxContent",string.format("%s%s%s%s%s%s%s",z1,"\n",z2,"\n",z3,"\n",z4)) 
    

    Same problem. LUA issue ?

    #23879
    dasfaker
    Keymaster
    • Topics: 80
    • Replies: 793
    • Total: 873
    • ★★★

    Could there be some duplicated name? Some variable with the same name as some modulator or some data?

    #23886
    zeoka
    Participant
    • Topics: 73
    • Replies: 466
    • Total: 539
    • ★★★

    no
    A new panel checked the modulator list names ,vst indexes …

    updlbl = panel:getComponent("TrigSel")
    lb1 = panel:getComponent("01SoundLabel"):getComponentText()
    panel:getComponent("modulator-5"):setText(lb1)
    console(lb1)
    lb2 = panel:getComponent("02SoundLabel"):getComponentText()
    panel:getComponent("modulator-7"):setText(lb2)
    console(lb2)
    lb3 = panel:getComponent("03SoundLabel"):getComponentText()
    panel:getComponent("modulator-8"):setText(lb3)
    console(lb3)
    lb4 = panel:getComponent("04SoundLabel"):getComponentText()
    panel:getComponent("modulator-9"):setText(lb4)
    console(lb4)
    z1 = panel:getComponent("modulator-5"):getText()
    --w1 = string.format("%q",z1)
    z2 = panel:getComponent("modulator-7"):getText()
    --w2 = string.format("%q",z2)
    z3 = panel:getComponent("modulator-8"):getText()
    --w3 = string.format("%q",z3)
    z4 = panel:getComponent("modulator-9"):getText()
    --w4 = string.format("%q",z4)
         --string.gsub(panel:getComponent("modulator-5"):getText(), "(%w+)", print) tried to print :) 
    lbl = string.gsub("z1,z2,z3,z4",",","\n") 
    i = "\n"
         --lbl = string.format("%q%s%q%s%q%s%q",lb1,i,lb2,i,lb3,i,lb4) no
    updlbl:setPropertyString("uiListBoxContent",string.format("%s",lbl)) 
         -- i get row 1:z1  row2:z2 etc.. texts :( but it's a start . how to convert a function to string ? 
         --  string.format ?? :D   
    --updlbl:setPropertyString("uiListBoxContent",lb1)

    nothing to do ..

    #23899
    zeoka
    Participant
    • Topics: 73
    • Replies: 466
    • Total: 539
    • ★★★

    here is the panel
    If someone wants to look

    Attachments:
    You must be logged in to view attached files.
    #23915
    dasfaker
    Keymaster
    • Topics: 80
    • Replies: 793
    • Total: 873
    • ★★★

    The problem here is that the listBox content is user data, and not a string. Can’t find a way to extract a string from there.

    The best solution I see is, as you know the content of the listBoxes, create a list with the content of the listBoxes (list = {“BassDrum 1″,”BassDrum 2″,”Bass”,
    “Bass Saw”…}) and as you can get the row selected on the list box, pass this value to the list, this way you get a string.

    #23916
    zeoka
    Participant
    • Topics: 73
    • Replies: 466
    • Total: 539
    • ★★★

    Thank you Dasfaker
    You’re right it’s damage to add a table while I keep especialy 24 litbox contents for easy use
    I planned to add a tab with the 24 + 1 listboxes
    I double click on the soundselect listbox goes to selected sound label tab. I click on a label the tab goes to the soundselect listbox
    if I don’t click until 10 sec it returns to soundselect listbox

    well I plan to get label listboxes component text ,transforms them as a table ,get label boxes values and string.format with tables that’s sure method
    At least I’ll write a table
    Thank you again Dasfaker

    #23918
    zeoka
    Participant
    • Topics: 73
    • Replies: 466
    • Total: 539
    • ★★★

    I get it !

    
    label = function(mod, value)
    
    updlbl = panel:getComponent("TrigSel")
    lb1 = panel:getComponent("01SoundLabel"):getComponentText()
    panel:getComponent("modulator-5"):setText(lb1)
    
    lb2 = panel:getComponent("02SoundLabel"):getComponentText()
    panel:getComponent("modulator-7"):setText(lb2)
    
    lb3 = panel:getComponent("03SoundLabel"):getComponentText()
    panel:getComponent("modulator-8"):setText(lb3)
    
    lb4 = panel:getComponent("04SoundLabel"):getComponentText()
    panel:getComponent("modulator-9"):setText(lb4)
    
    z1 = panel:getComponent("modulator-5"):getProperty("uiLabelText")
    z2 = panel:getComponent("modulator-7"):getProperty("uiLabelText")
    z3 = panel:getComponent("modulator-8"):getProperty("uiLabelText")
    z4 = panel:getComponent("modulator-9"):getProperty("uiLabelText")
     
    i = "\n"
    lbl = string.format("01: %s%s02: %s%s03: %s%s04: %s",z1,i,z2,i,z3,i,z4) 
    updlbl:setPropertyString("uiListBoxContent",string.format("%s",lbl)) 
    

    I need to check inside the label cpp if I see magic formula inside
    “Called when the contents of a Label are changed” or in the component
    Atom ?

    #23951
    atom
    Keymaster
    • Topics: 159
    • Replies: 2945
    • Total: 3104
    • ★★★★★

    What would you like to know ? I don’t think i got the question.

    #23952
    zeoka
    Participant
    • Topics: 73
    • Replies: 466
    • Total: 539
    • ★★★

    Hi Atom
    I would like to know how I could replace texts used to get the component text and to send to string.format formula ?
    getComponentText -> label:setText = string
    getComponentText -> string.format or whatever string.* = userdata
    label:getProperty(“uiLabelText”) -> string.format = string
    possible to convert ?

    #23953
    atom
    Keymaster
    • Topics: 159
    • Replies: 2945
    • Total: 3104
    • ★★★★★

    I still don’t get it, you want to replace “texts” used to get “component text” and send to string.format formula >

    I really don’t know what do you mean…

Viewing 16 posts - 1 through 16 (of 16 total)
  • The forum ‘Programming’ is closed to new topics and replies.
There is currently 0 users and 56 guests online
No users are currently active
Forum Statistics
Threads: 2,495, Posts: 17,374, Members: 77,605
Most users ever online was 12 on January 22, 2019 3:47 pm
Ctrlr