Reply To: randomize a text label?

Home Forums General Programming randomize a text label? Reply To: randomize a text label?

#73352
human fly
Participant
  • Topics: 124
  • Replies: 1070
  • Total: 1194
  • ★★★★

maybe more something like this? missing how to apply the random:
(at the moment, it can get the bytes individually and put them back
together again)

function createRandomName()
-- create a random preset name

	-- This variable stops index issues during panel bootup
	if panel:getRestoreState() == true or panel:getProgramState() == true then return end

	presetName = L(panel:getModulatorByName("lcd_presetName"):getComponent():getProperty("uiLabelText"))
	console("Retreiving preset name from lcd_presetName : "..presetName)

-- Store each character in variable
	local name1 = string.byte(presetName,1)
	local name2 = string.byte(presetName,2)
	local name3 = string.byte(presetName,3)
	local name4 = string.byte(presetName,4)
	local name5 = string.byte(presetName,5)
	local name6 = string.byte(presetName,6)
	local name7 = string.byte(presetName,7)
	local name8 = string.byte(presetName,8)
	local name9 = string.byte(presetName,9)
	local name10 = string.byte(presetName,10)

-- random seeder
	local t=os.time()
	local c=os.clock()
	math.randomseed(t*c)

-- items to randomize
	tabl_NewName={}
		for j= 1,10 do
		rnd=math.random(32,127) --value range to random

--		/////what here?///// --(rnd,false,false,false)
--		table.insert(tabl_NewName,j)
		end

-- put bytes in table as characters
	if name1 == nil then name1 = " " end
	tabl_NewName[1] = string.char(name1)
	
	if name2 == nil then name2 = " " end
	tabl_NewName[2] =  string.char(name2)			
	
	if name3 == nil then name3 = " " end
	tabl_NewName[3] =  string.char(name3)

	if name4 == nil then name4 = " " end
	tabl_NewName[4] =  string.char(name4)

	if name5 == nil then name5 = " " end
	tabl_NewName[5] =  string.char(name5)

	if name6 == nil then name6 = " " end
	tabl_NewName[6] =  string.char(name6)

	if name7 == nil then name7 = " " end
	tabl_NewName[7] =  string.char(name7)
	
	if name8 == nil then name8 = " " end
	tabl_NewName[8] =  string.char(name8)
	
	if name9 == nil then name9 = " " end
	tabl_NewName[9] =  string.char(name9)			
	
	if name10 == nil then name10 = " " end
	tabl_NewName[10] =  string.char(name10)

--concatenate table into single string
	DatasConcat = table.concat(tabl_NewName, "", 1, 10)
	console ("DatasConcat : "..DatasConcat)

--send it to preset name lcd
	panel:getComponent("lcd_presetName"):setPropertyString("uiLabelText",""..DatasConcat)
end
Ctrlr