Log In    |    Knowledge Base    |    4D Home
Tech Tip: Method to parse project mode conversion log
Published On: April 18, 2022

When exporting a binary structure to project mode, there may be errors and warnings associated with the project conversion, recorded in the conversion log. It is useful to have a list of each type of error/warning, as well as their counts. The method below parses the conversion log and groups the errors and warnings into text. The text is then saved in a file on disk. The text displays an overview of the amount of each type of error or warning.

C_TEXT($file_t; $verifyLog_t; $message_t; $logParse_t; $msg_t; $count_t)
C_OBJECT($json_o; $warnings_o; $errors_o; $msg_o)

$file_t:=Select document(Get 4D folder(Logs folder); "*"; "List of Logs"; 2)

If (OK=1)
     $verifyLog_t:=Document to text(Document; UTF8 C string)
     $json_o:=JSON Parse($verifyLog_t)
     $warnings_o:=New object
     $errors_o:=New object

     For each ($msg_o; $messages_c)

       If ($msg_o.severity="warning")

         If (Value type($warnings_o[$message_t])=Is undefined)
         End if

         If ($msg_o.severity="error")
           If (Value type($errors_o[$message_t])=Is undefined)
           End if

         End if

       End if

     End for each

End if

For each ($msg_t; $errors_o)
  $logParse_t:=$logParse_t+Char(Carriage return)+$msg_t+Char(Tab)+$count_t
End for each

$logParse_t:=$logParse_t+Char(Carriage return)+Char(Carriage return)+"Warnings"
For each ($msg_t; $warnings_o)
  $logParse_t:=$logParse_t+Char(Carriage return)+$msg_t+Char(Tab)+$count_t
End for each

TEXT TO DOCUMENT("logParse.txt"; $logParse_t)
SHOW ON DISK("logParse.txt")

After the method is executed, select and open the conversion log from the Logs folder. Then, after the method finishes, the text file will be generated next to the structure file, and its location shown on disk. Example of the result:

'Background offset' 3D button style is not supported. 18
Unsupported form object type. 2

Compatibility setting 'Fields are enterable in dialog boxes' switched on. 1
Compatibility setting 'Radio buttons grouped by name' switched off. 1

The total amount of each type of error or warning will be listed next to its description. In the above example, there are 18 instances of ‘Background offset 3D button’ errors, and 2 instances of ‘Unsupported form object type’ errors. All errors should be addressed when converting a binary application to project application.