Converting a Data Event Variable to a Level
davegrov
Posts: 114
I am parsing out a light level form a lighting program and want to convert it to a level to send to a T.
How do I convert a variable to a value that can be sent to a TP Bargraph?
How do I convert a variable to a value that can be sent to a TP Bargraph?
0
Comments
STRING:
{
SELECT
{
ACTIVE(FIND_STRING(DATA.TEXT,'DL,',1)):
{
ltLevel = (RIGHT_STRING(DATA.TEXT,2))
nLight = ((MID_STRING(DATA.TEXT,7,2))
SEND_LEVEL dvTP_Lights, ATOI(nlight+9), ATOI(ltLevel)
}
}
}
Should we have a separate thread combining all these type of questions? Time's wasting.
What does the TYPE_CAST do?
I'm still stumped.
ACTIVE(find_string(data.text,'DL,,50
{
stextBuffer=(DATA.TEXT)
remove_string(sTextBuffer,':',1) // sTextBuffer Now = 4],50
nLightzone= atoi(sTextBuffer) //nLightzone= ? sTextBuffer is =4],50
remove_string(sTextBuffer,',',1) //sTextBuffer = 50
nlightLevel[nLightzone] = type_cast(type_cast(atoi((sTextBuffer)) + 9))
send_level dvTP_Lights, nlightLevel[nLightzone], nlightLevel[nLightzone]
}
If the lights are 0-100 based I would forgo the multiplication and just make the bargragh 0-100 too and then send straight level values w/o conversion.
Now depending on the value received you may stil need to convert from ascii to integer like above.