Tech Tip: Exporting a list of all 4D processes
PRODUCT: 4D | VERSION: 11.4 | PLATFORM: Mac & Win
Published On: June 24, 2009
Sometimes it may be useful to export a list of all 4D processes. This can be used for debugging, troubleshooting, or simply for logging purporses.
The follwing method can be used to export such a list in Tab delimited format. Note that the "SEND PACKET" lines of code are very long and break over multiple lines in the example below:
C_TIME($theDoc) C_TEXT(procName) C_LONGINT($a;taskCount_l;procState;procTime;uniqueID;origin) C_BOOLEAN(procVisible) taskCount_l:=Count tasks $theDoc:=Create document("the_processes.txt") ` SEND PACKET line breaks, caution when copying and pasting code SEND PACKET($theDoc;"ID"+Char(Tab )+"NAME"+Char(Tab )+"STATE"+Char(Tab )+"TIME"+Char(Tab )+"VISIBLE"+Char(Tab )+"UID"+Char(Tab )+"ORIGIN"+Char(Carriage return )) For ($a;1;taskCount_l) PROCESS PROPERTIES($a;procName;procState;procTime;procVisible;uniqueID;origin) ` SEND PACKET line breaks, caution when copying and pasting code SEND PACKET($theDoc;String($a)+Char(Tab)+procName+Char(Tab)+String(procState)+Char(Tab )+String(procTime)+Char(Tab )+String(procVisible)+Char(Tab)+String(uniqueID)+Char(Tab)+String(origin)+Char(Carriage return )) End for CLOSE DOCUMENT($theDoc) |
The code simply creats a text document to store the process data and then runs through a list of processes, obtained via the Count tasks and PROCESS PROPERTIES commands. Each process's data is written to the file.
Commented by Luis on June 26, 2009 at 5:38 PM
You can extend the value of this method by adding a small subroutine for the procState and the origin parameters where instead of showing the numerical value it can show the Constant. For instance, if the procState is -1 your log could read Aborted instead.