Is there a function that closes all open or used files?

This forum is for eXpress++ general support.
Post Reply
Message
Author
User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

Is there a function that closes all open or used files?

#1 Post by Eugene Lutsenko »

hi!
Is there a function that closes all open or used files?

There are wonderful functions: CLoseAll() and Close AllWindows(). But we also need the CloseAllFiles() function

Code: Select all

******************************************************************************************
Function CLoseAll()            // Закрытие всех баз данных с ожиданием завершения операций
******************************************************************************************
LOCAL bError , aWorkareas , x, y

bError := ErrorBlock( {|e| Break(e)} )
aWorkAreas := workspacelist()
y := len(aWorkAreas)

for x = 1 to y
  BEGIN SEQUENCE
    (aWorkAreas[x])->(DbClearRelation())
    (aWorkAreas[x])->(DbCloseArea())
  ENDSEQUENCE
next
ErrorBlock(bError)
bError   := nil
Return nil

Code: Select all

************************************************************************************
******** Закрыть все процессы от Роджера
************************************************************************************
FUNCTION CloseAllWindows()

LOCAL i, aChildList, nSeconds := Seconds()

DO WHILE !Empty( aChildList := Set_MainWindow():drawingArea:childList())

  FOR i := 1 TO Len(aChildList)
    IF !aChildList[i]:isDerivedFrom('XbpDialog')
      aChildList[i]:destroy()
    ELSE
      PostAppEvent(xbeP_Close,,,aChildList[i])
    ENDIF
    Sleep(10)
  NEXT

  IF Seconds() - nSeconds > 10
    EXIT
  ENDIF

ENDDO

Sleep(10)

RETURN nil
************************************************************************************

User avatar
Auge_Ohr
Posts: 1405
Joined: Wed Feb 24, 2010 3:44 pm

Re: Is there a function that closes all open or used files?

#2 Post by Auge_Ohr »

hi Eugene,

there is a "wonderful" Function : QUIT

IMHO it is recommend to "close DBF" as soon as possible when not need any more
greetings by OHR
Jimmy

User avatar
Tom
Posts: 1165
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: Is there a function that closes all open or used files?

#3 Post by Tom »

Don't forget: Workareas are thread-local.
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

Re: Is there a function that closes all open or used files?

#4 Post by Eugene Lutsenko »

Hi, Jimmy!

Of course, the QUIT function is definitely wonderful. but it has one drawback: it causes the program to stop working. And I need a similar function that I want to use before going to the main menu of my system

skiman
Posts: 1183
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: Is there a function that closes all open or used files?

#5 Post by skiman »

Hi,

That closeall() function closes all the files in the current thread. If you execute it before returning to your main menu, everything should be closed.
Best regards,

Chris.
www.aboservice.be

User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

Re: Is there a function that closes all open or used files?

#6 Post by Eugene Lutsenko »

skiman wrote: Mon Nov 21, 2022 2:26 am Hi,

That closeall() function closes all the files in the current thread. If you execute it before returning to your main menu, everything should be closed.
Databases are index arrays, yes. And just busy (open) files?

User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

Re: Is there a function that closes all open or used files?

#7 Post by Eugene Lutsenko »

hi, Roger!

Is it possible to make your CLoseAllWindows() function not give errors if there are no open windows?

User avatar
Tom
Posts: 1165
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: Is there a function that closes all open or used files?

#8 Post by Tom »

Just embed in a sequence:

Code: Select all

LOCAL bError := ErrorBlock({|e|Break(e)})
BEGIN SEQUENCE

(do what you want that should not create runtime errors, maybe "CloseAllWindows")

END SEQUENCE
ErrorBlock(bError)
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

Re: Is there a function that closes all open or used files?

#9 Post by Eugene Lutsenko »

Thank you, Tom! How did I not guess myself:) Probably because it's easier to ask you than to think for yourself

Post Reply