I'm supporting an application that writes system messages to a file using an export. The messages are also added to a table component that reflects a v.channel that contains all the entries. When the application is started the export file is read and stuffed into the table.
The problem is that the startup stuff is entered backwards... time goes backwards for all past entries. New system messages ("Restart' etc) appear in proper chronological order, with the most recent at the top.
Here's some code:
<>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Sequence.loadMessages, Priority: 5 - Acquisition
// pass name of export set used to write, and the name of the destination v channel (with v.). For example:
// loadMessages("message_export","v.SYSTEM_MESSAGES")
function loadMessages(string exportName, string destination)
try
private handle = evaluate("file.Open(export." + exportName + ".strFileName,1,0,0,1)")
file.Read(handle) // read header
private theTime = file.ReadDelim(handle, 0, ",", chr(10), -1)
file.SeekToBegin(handle)
file.Read(handle) // read header
private string messages = file.ReadDelim(handle,1,",",chr(10),-1,1)
messages.time = (theTime - 365*70 - 19) * 86400
execute(destination + ' = "START OF MESSAGES "')
execute(destination + ".AddValue(messages)")
file.Close(handle)
catch()
? strLastError
endcatch
function add_service_Message(string message)
v.service_messages.addvalue(formatdateTime("%c", systime()) + ": " + message)
delay(.01)
beginexport(service_export)
endfunction
</>
Is there a way to invert the row order of the array 'messages'? Is there a way to read the file from the bottom? Not seeing an easy way out here.
__
Steve
.