KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Determine Object Method JSON is corrupted
PRODUCT: 4D | VERSION: 16 | PLATFORM: Mac & Win
Published On: March 17, 2018

The file ObjectMethodEditor.json saves the window bound settings of thelast opened method editor window. When a method is opened, it will display on that last location that the JSON file wrote to. If this file is corrupted, newly created methods will be opened in a non visible location. Here are possible scenerios that the file could be corrupted:

1. A computer that has dual screens may save the method editor window on the screen that is disconnected.

2. A method that is opened could have closed improperly and thus save the incorrect window bounds.

3. A ObjectMethodEditor.json was corrupted which contained incorrect settings.

4. A maximized 4D window environemnt may saved the settings but could not recalculate if the 4D window environment was minimized.

The following utility method will determine if the file is corrupted:

// ----------------------------------------------------------------------
// Name: CHECK_OBJ_METHOD_EDITOR_JSON
// Description: Method will determine if the ObjectMethodEditor.json is
// corrupted where this setting can affect viewing newly created methods
// in the method editor.
//
// Output:
// $0 (LONGINT) - Status of the file
// 0 - normal
// 1 - corrupted
// -1 - file not found
// ----------------------------------------------------------------------
C_TEXT($appVer;$path;$fs)
C_LONGINT($0;$status;$leftB;$topB;$widthB;$heightB)
C_OBJECT($obj)

// Getting the application version
$appVer:=Application version
$appVer:=$appVer[[1]]+$appVer[[2]]
$fs:=Folder separator

$path:=Get 4D folder(Active 4D Folder)+"4D Window Bounds v"+$appVer+\
       $fs+"development"+$fs+"[projectForm]"+$fs+"ObjectMethodEditor.json"

$status:=0

If (Test path name($path)=Is a document)
  $obj:=JSON Parse(Document to text($path))
  $objSub:=Ob Get($obj;"bounds")
  $leftB:=OB Get($objSub;"left")
  $topB:=OB Get($objSub;"top")
  $widthB:=OB Get($objSub;"width")
  $heightB:=OB Get($objSub;"height")
 
  If (($leftB<0) | ($leftB>10000))
    $status:=$status+1
  End if
 
  If (($topB<0) | ($topB>10000))
    $status:=$status+1
  End if
   
  If (($widthB<0) | ($widthB>10000))
    $status:=$status+1
  End if
   
  If (($heightB<0) | ($heightB>10000))
    $status:=$status+1
  End if
   
  If ($status>=1)
    $0:=1
  Else
    $0:=0
  End if
Else
  $0:=-1 // No file found
End if


Here is an example of using the command:

C_LONGINT($status)

$status:=CHECK_OBJ_METHOD_EDITOR_JSON
// 0 - No issue
// 1 - Corrupted
// -1 - File not found