Is it possible to write something in a specific line in a uilistbox?

Home Forums General Programming Is it possible to write something in a specific line in a uilistbox?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #69460
    iceleben
    Participant
      • Topics: 7
      • Replies: 13
      • Total: 20

      Hi as the title says is it possible to easy fill a line in an UiList Box?
      like
      replace=panel:getListBox(“RAM1ToneBank”):setPropertyString(“uiListBoxContent”,”word”)
      and lets say and want that in line 8?

      Thx

      #69461
      Puppeteer
      Participant
        • Topics: 16
        • Replies: 185
        • Total: 201
        • ★★

        No, you can only replace the entire string.

        Best way is create a table to hold each line. Update the relevant table entry.

        When you need to update the list is content call a method that cycles through each table element concatenating with /N and then write the resulting string to the list is.

        There’s an example in the miniak panel for the program list.

        The Puppeteer
        http://godlike.com.au

        #69465
        iceleben
        Participant
          • Topics: 7
          • Replies: 13
          • Total: 20

          ahh damnit, I already did that once in this Panel but thought, hey maybe theres an easier/better way. Thanks!

          #69469
          goodweather
          Participant
            • Topics: 45
            • Replies: 550
            • Total: 595
            • ★★★

            Without knowing it was in another panel, I have also used that technique: rebuilding and replacing the full string of names.
            This is faster and easier than searching in the content string and replacing a piece (you need to store what is before and what is after) of it.

            I put this in a separate method that I can call for any listbox: RefreshListBoxContent(memoryblock). So, only one program but re-used several times 🙂
            It is based on a memory block in my case as I have sound banks as memory blocks and I extract the program names from the bank (20 char string).

            Here is the code you can get inspired from:

            RefreshBankListBox = function(mbBank)
            
            	FileSize = mbBank:getSize()
            
            	if FileSize == 116622 then
            		sListBoxContent = ""
            		for i=0, 98 do
            			UnpackedTempData = utils.unpackDsiData(mbBank:getRange (438+i*1178, 24))
            			sTemp = trim(UnpackedTempData:getRange (0, 20):toString())	-- Remove blanks
            			sTemp = sTemp:gsub("'", " ")	-- Replace ' by a space as it gives issues in the listbox
            			sTemp = sTemp:gsub("\"", " ")	-- Replace " by a space as it gives issues in the listbox
            			if i==0 then
            				sListBoxContent = sListBoxContent..string.format("%s", "P1 "..sTemp)
            			else
            				sListBoxContent = sListBoxContent..string.format("\n%s", "P"..tostring(i+1).." "..sTemp)
            				--sListBoxContent = sListBoxContent..", \""..sTemp.."\""
            			end
            		end
            		return sListBoxContent
            	else
            		utils.warnWindow("Refresh bank list box", "Error: bank data not of correct size. Should be 116622 and is "..FileSize.." bytes.")
            	end
            
            end

            To use it:
            lbUser1:setPropertyString ("uiListBoxContent", RefreshBankListBox(mbUser1))

            With lbUser1 being a uiListBox declared as:
            lbUser1 = panel:getListBox("User1")

          Viewing 4 posts - 1 through 4 (of 4 total)
          • The forum ‘Programming’ is closed to new topics and replies.
          There is currently 0 users and 71 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