Foxtools – Editor _EDCLOSEFI

Version: 01.50.00 - last Update: Tuesday, October 13, 2009, 11:55:00

Previous ChapterFoxtools Home (Alphabetical TOC)Foxtools Home (Grouped TOC)Next Chapter See also:_EdOpenFil | _EdRevert | _EdSelect | _EdIndent | _EdInsert | _EdSendKey | _EdDelete | _EdComment


Foxtools Editor Support Functions

_EDCLOSEFI

_EdCloseFi() Closes the editor session window passed in <nWHAND> parameter.

VFP Syntax

nResult = _EdCloseFi(nWHAND, nCloseFlag)

Parameters

[in] nWHAND

Fox-window handle of the editor session to be closed.

[in] nCloseFlag

nCloseFlag can be one of the following values

  • 0 := Save file and close editor window immediately without confirmation dialog.
  • 1:= Show confirmation dialog (User can select to SAVE, DISCARD and CANCEL).
  • 2:= Open a SAVE AS… dialog.

Returns

Numeric; the return value tells us what happened:

  • 0 := the editor session content was successfully saved.
  • -1 := the user discarded all changed (did not save).
  • 1 := the user cancelled closing the editor session (editor is still open)

Remarks

_EdCloseFi() is the programmatic approach to close an editor session. Passing a <0> in nCloseFlag does a forced save (if editor session’s text buffer is dirty) without displaying any confirmation dialogs. Passing <1> or <2> always shows a dialog the user may cancel! Thus, neither take for granted that the editor session content was saved, nor the session was closed.

VFP Example(s)

Opening/closing an Editor session can be accomplished with the following:

#DEFINE ED_READONLY  0
#DEFINE ED_WRITEONLY 1
#DEFINE ED_READWRITE 2

PUBLIC gEdit AS EditorSession
LOCAL lcText AS STRING, lnReturn AS INTEGER

*\\ open some text file using read/write mode
gEdit = _EDOPENFIL(GETFILE("txt","Open"), ED_READWRITE)
*\\ if GETFILE() cancelled, gEdit will be negative
IF m.gEdit > -1
  *\\ success - editor session is open
  lcText = "Hello world"
  *\\ let's make session buffer dirty
  = _EDINSERT(m.gEdit, m.lcText ,LEN(m.lcText))
  *//
  *\\ Uncomment lines to see the effects
  #DEFINE ED_SAVE_FORCED	0
  #DEFINE ED_SAVE_DIALOG	1
  #DEFINE ED_SAVE_AS		2
*** lnReturn = _EDCLOSEFI(m.gEdit, ED_SAVE_FORCED) *** lnReturn = _EDCLOSEFI(m.gEdit, ED_SAVE_DIALOG) lnReturn = _EDCLOSEFI(m.gEdit, ED_SAVE_AS) *// *\\ Check if editor session was closed #DEFINE ED_SAVED 0 #DEFINE ED_DISCARD -1 #DEFINE ED_CANCEL 1 DO CASE CASE m.lnReturn = ED_CANCEL ? "Editor session still running" CASE m.lnReturn = ED_DISCARD ? "Editor session closed - changes discarded" CASE m.lnReturn = ED_SAVED ? "Editor session closed - changes saved" ENDCASE *// ENDIF

Previous ChapterFoxtools Home (Alphabetical TOC)Foxtools Home (Grouped TOC)Next Chapter