Last active
February 11, 2020 14:08
-
-
Save jbratu/f26d79309d6ba7bdc4ec to your computer and use it in GitHub Desktop.
Display the last date and time an OpenInsight program was compiled. Specify the name of the stored procedure and the routine will extract the username and compile date time from the end of the compiles routine.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function CS_GetCompileDate(Routine) | |
* | |
* Read a compiled routine and extract the last compiled date and time stamp. | |
* | |
* Params: | |
* Routine - Name of the routine in the current OI application | |
* | |
* Returns: | |
* Displays the date time in a message box. Also returns the value. | |
* | |
* Last Revised: 2016-04-17 | |
Declare Function Read_Row, Index | |
*Name of the compiled routine. Assumes current application. | |
Convert @LOWER_CASE To @UPPER_CASE In Routine | |
Key = '$' : Routine : '*' : @APPID<1> | |
*Table containing compiled routines | |
OBJTableName = "SYSOBJ" | |
Open OBJTableName To Table Else | |
Call FSMsg() | |
Return '' | |
End | |
Read ObjCode From Table, Key Else | |
Call Msg("Unable to read " : KEY : " from " : OBJTableName) | |
Return '' | |
End | |
ObjCodeLen = Len(ObjCode) | |
*Find the last field in the record - it contains the date time | |
Chunk = ObjCode[-1,'B':@FM] | |
*Based on where the last field was, look backward a little further for the compile by ID | |
*It will be prefixed by two nulls | |
SearchToken = \00\:\00\ | |
*Calculate the start of the two nulls from the end of the string | |
BackOffset = Len(Chunk) + Len(SearchToken) | |
BackOffset = -1 * BackOffset | |
*Extract from the start of the last field backward to the the start of the two nulls | |
CompiledBy = ObjCode[BackOffset, 'B':SearchToken] | |
*Trim the last field up to the first space to get only the date time | |
SearchToken = \00\ | |
EndCodePos = Index(Chunk, SearchToken,1) | |
*Trim the chunk down, start at the character after the search token. | |
TimeChunk = Chunk[1, EndCodePos] | |
*Look for a NULL character at the end of the time chunk so we know where DateTime value ends | |
EndDelimPos = Index(TimeChunk, \00\, 1) | |
*Internal DateTime value ends 2 bytes before the end of the null char | |
DateTimeI = TimeChunk[1, (EndDelimPos - 2)] | |
*Convert to internal for display | |
DateTimeO = OConv(DateTimeI,'DT2/^H') | |
Call Msg("Progam last compiled " : DateTimeO : " by " : CompiledBy) | |
Return DateTimeO |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment