About Store Forum Documentation Contact



Post Reply 
How does "reloadElm();" works?
Author Message
mizukami Offline
Member

Post: #1
How does "reloadElm();" works?
i cannot understand that "EditorInterface.reloadElm();" works.

"reloadElm();" requests reload a file from "src_file" and always returns TRUE.
then, in case of "Edit.ELM_FILE", these codes are generally same?

* Code A:
Code:
Bool  b;
b = EI.reloadElms(elms[i].id);

* Code B:
Code:
Bool  b;
File file;
Str filePath;

filePath = elms[i].src_file;
file.read(filePath, EE_PROJECT_CIPHER);
b = EI.setFile( elms[i].id, file );

and why returns always TRUE?
(whether "src_file" is present or not)
05-26-2016 11:17 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: How does "reloadElm();" works?
Hello,

Please kindly read the comments for the reload function:
Code:
Bool   reloadElms (C MemPtr<UID> &elms                            ); // reload elements specified by their ID, elements will be reloaded from their current 'Elm.src_file', which can be changed using the 'setElmSrcFile' method. This method does not wait until elements finish reloading, it only requests the reload, and returns true if the request was accepted, and false if request failed. Which means that even if this method returns true, reload may still fail, for example if the element 'src_file' was not found.
05-27-2016 06:04 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #3
RE: How does "reloadElm();" works?
As for Code B,
then calling File.read should actually Exit if the file is not found.
Code:
File& read       (C Str     &name, const_mem_addr Cipher *cipher=null); // read Pak or stdio file, Exit on fail, 'cipher' must point to object in constant memory address (only pointer is stored through which the object can be later accessed)

You should use:
bool ok=file.readTry(name);
05-27-2016 06:16 AM
Find all posts by this user Quote this message in a reply
mizukami Offline
Member

Post: #4
RE: How does "reloadElm();" works?
we using many data files that edited(made) outside of EE.
These files type are ELM_CODE(text) or ELM_FILE(binary).

Once file modified, "Reload" operation needed on EE. However this makes mistake.
So, i made reload app. like below.

Code:
FREPA(elms)
{
  switch(elms[i].type)
  {
  ...
  case Edit.ELM_CODE:
  case Edit.ELM_FILE:
    EI.reloadElm(elms[i].id);
    break;
...
}

But "realoadElm();" always returns TRUE.
in team operation(team environment), "elms[i].src_file" sometimes not present.
Reload path mismatch(absolute(user owned) directory), or commit miss.
However "reloadElm();" cannnot check it.

i should not use "reloadElm();"? and what situation shoud i use?
05-27-2016 06:32 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #5
RE: How does "reloadElm();" works?
You can use something like this:
Code:
bool SourceExists(C Str &src_file)
{
   Mems<Edit.FileParams> files=Edit.FileParams.Decode(src_file);
   REPA(files)if(!FExistSystem(files[i].name))return false;
   return true;
}
FREPA(elms)
{
   bool src_exists=SourceExists(elms[i].src_file);
05-27-2016 07:04 AM
Find all posts by this user Quote this message in a reply
mizukami Offline
Member

Post: #6
RE: How does "reloadElm();" works?
Thank you!

But "SourceExists(C Str &src_file);" is not functioned at "src_file" is relative.
# "src_file" often set relative directory.
05-27-2016 07:57 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #7
RE: How does "reloadElm();" works?
Hello,

Quote:-added new EditorInterface methods 'reloadResult' and 'forgetReloadResult'
This should solve the problem.
05-31-2016 11:38 PM
Find all posts by this user Quote this message in a reply
Post Reply