Forum > General

Actions and Reslts

(1/4) > >>

Weitentaaal:
Hello,

i have an Action which handles the Saving for me.
This Code is in my Saving algorithm:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---         if FileExists(FilePath) then begin            if CustomMessage('', Get_TxInLng(4263), cmQuestion) <> mrYes then begin               Cursor:= crDefault;               Exit;            end;         end; 
which is checking if the File Exists and then asks if it should be overriden.

Now i have an OpenProject Action too. But that action checks if the current project is saved, if that is not the Case then i call this:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---actFileSaveAs.Execute; 
can i somehow check the result of the save dialog ?
i need to check if the Save Dialog was canceled.

im fairly new to Actions / ActionList, so any hints would be appreciated.

Thanks !

Zvoni:
?!?!?! --> https://wiki.freepascal.org/Howto_Use_TSaveDialog

--- Quote ---The Execute method displays the file save dialog. It returns true when user has selected a file, false when user has aborted.
--- End quote ---

Weitentaaal:
hey I have described the problem incorrectly.
This is my save dialog:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TStartUp.actFileSaveAsAccept(Sender: TObject);var   FilePath: string; begin   Cursor:= crHourGlass;   if actFileSaveAs.Dialog.Execute then begin      FilePath:= actFileSaveAs.Dialog.FileName;      if not (acPath= FilePath) then begin         if FileExists(FilePath) then begin            if CustomMessage('', Get_TxInLng(4263), cmQuestion) <> mrYes then begin               Cursor:= crDefault;               Exit;            end;         end;         //Save         try           //.....         except            on e:Exception do begin               CustomMessage('', 'failed to Save File ! '+sLineBreak+'Exception raised: '+e.Message+'', cmError);            end;         end;      end;   end;   Cursor:= crDefault;end; 
within the Code is this Line : if CustomMessage('', Get_TxInLng(4263), cmQuestion) <> mrYes then begin
which will check if the File exists and if it should be overriden. if the user does abort this Dialog then i would like to give back a result

if i do this:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---actFileSaveAs.Execute; 
can i somehow get back any result from the Execute method ?

TRon:

--- Quote from: Weitentaaal on June 05, 2023, 09:22:07 am ---can i somehow get back any result from the Execute method ?

--- End quote ---
I am not familiar with TActions but the documentation does state that the execute method returns a boolean value. So depending on what you return in your execute method ?

Weitentaaal:

--- Quote from: TRon on June 05, 2023, 09:29:42 am ---
--- Quote from: Weitentaaal on June 05, 2023, 09:22:07 am ---can i somehow get back any result from the Execute method ?

--- End quote ---
I am not familiar with TActions but the documentation does state that the execute method returns a boolean value. So depending on what you return in your execute method ?

--- End quote ---

i have seen that but i don't know how to set the result value, if its even possible to set it

Navigation

[0] Message Index

[#] Next page

Go to full version