I have a Log page which uses the Data object to store various events in my application.
On the Log page I have added a global string variable which holds the line event details to be logged and a hidden Hotspot object which, in its touch event, adds a timestamp to the event line and inserts the result into the Data object. See below:
// Log_Line contains log entry in the form Type^Message
// Build up a time stamp in s_logtmp
// Build Date in the form DD/MM/YY
covx gDy,s_logtmp.txt,2,0
s_logtmp.txt+="/"
covx gMnt,s_logtmp2.txt,2,0
s_logtmp.txt+=s_logtmp2.txt
s_logtmp.txt+="/"
covx gYr,s_logtmp2.txt,2,0
s_logtmp.txt+=s_logtmp2.txt
s_logtmp.txt+=" "
// Build Time in the form HH:MM
covx gHr,s_logtmp2.txt,2,0
s_logtmp.txt+=s_logtmp2.txt
s_logtmp.txt+=":"
covx gMn,s_logtmp2.txt,2,0
s_logtmp.txt+=s_logtmp2.txt
s_logtmp.txt+="^"
// Create full record in s_logtmp in the form
// DD/MM/YY HH:MM^Type^Message
s_logtmp.txt+=Log_Line.txt
// Add entry to Data file
data0.insert(s_logtmp.txt)
// Update the Record count and max value
covx data0.qty,RecCnt.txt,0,0
RecCnt.txt+="/"
covx data0.maxval,s_logtmp.txt,0,0
RecCnt.txt+=s_logtmp.txt
This works fine while the Log page is the active page but if I try and run the click event while on another page in the application I get an invalid component error.
click Log.Update,0 // results in an invalid component
How can I add items to the Data object without having the data object currently visible. I have made the Log page, Update object and Log_Line objects Global but I still get Component Invalid error.
The example in the Nextion Blog assumes every thing is running on the same page but for all real world applications the it has to be possible to add items to a Data object behind the scenes.
John Barrat