Re: Backup problem
'below is the xbasaic equivalent to Stan Mathew's solution...
in case you want additional customization.
'Display the 'Backup Database' dialog box
dim cmd_initial as c
cmd_initial = " backup_database()"
dim msg as c
msg = "In order to Backup files, all open Windows must first be closed. OK to close all open Windows?"
dim cmd_result as c
'get list of all open windows...........................................
dim open_windows as c
open_windows = a5_list_open_windows()
dim current_window as c
if is_object(topparent.this)
if topparent.class() = "form" .or. topparent.class() = "browse" then
current_window = topparent.name()
'remove the current window from the list
open_windows = word_subtract(open_windows,current_window,crlf())
end if
end if
'generate the xbasic to close all of the open windows (excepting the current window)....................
if open_windows <> "" then
dim cmd_close as c
cmd_close = *for_each(x,x+".close()" , open_windows)
''now execute the xbasic
cmd_result = evaluate_template(cmd_close)
if cmd_result <> "" then
ui_msg_box("Error",cmd_result)
goto skip_rest_close_open_windows
end if
end if
if is_object(topparent.this) then
if topparent.class() = "form" .or. topparent.class() = "browse" then
dim q_msg as n
q_msg = ui_msg_box("Notice",msg,UI_ATTENTION_SYMBOL+UI_OK_CANCEL)
if q_msg = ui_ok_selected then
dim topparent_name as c
dim cmd as c
dim condition as c
dim open_sessions as c
open_sessions = session_enum()
dim open_session_count as n
open_session_count = line_count(open_sessions)
if topparent.class() = "form" then
cmd = "dim tempP as p; tempP = form.view(" + quote(topparent.name(1)+"@" + topparent.Dictionary_Get(1))+")"
else
cmd = "dim tempP as p; tempP = browse.view(" +quote( topparent.name(1)+"@" + topparent.Dictionary_Get(1))+")"
end if
if a5_IsMaximized() = .t. then
cmd = cmd + crlf() +"xbasic_wait_for_idle()" + crlf() + "tempP.maximize()" + crlf()
end if
'when the number of sessions is one less than the number before the layout is closed then
'the session that the form/browse was based on has been closed, and it is safe to run the
'command.
condition = "line_count(session_enum()) = " + (open_session_count - 1 )
cmd = cmd_initial + crlf() + cmd
'is the control panel hidden? if so then you have to temporarily show it, or else the database will close
'after you close this form.
if ControlPanel.IsVisible() = .f. then
ControlPanel.Minimize()
cmd = cmd + crlf() + "controlpanel.hide()"
if a5_IsMaximized() then
topparent.restore()
end if
end if
on_condition(condition,cmd)
topparent.close()
end if
else 'topparent is an object, but it is not a form or browse
cmd_result = evaluate_template(cmd_initial)
if cmd_result <> "" then
ui_msg_box("Error",cmd_result)
end if
end if
else ' topparent is not an object
cmd_result = evaluate_template(cmd_initial)
if cmd_result <> "" then
ui_msg_box("Error",cmd_result)
end if
end if
skip_rest_close_open_windows:
'below is the xbasaic equivalent to Stan Mathew's solution...
in case you want additional customization.
'Display the 'Backup Database' dialog box
dim cmd_initial as c
cmd_initial = " backup_database()"
dim msg as c
msg = "In order to Backup files, all open Windows must first be closed. OK to close all open Windows?"
dim cmd_result as c
'get list of all open windows...........................................
dim open_windows as c
open_windows = a5_list_open_windows()
dim current_window as c
if is_object(topparent.this)
if topparent.class() = "form" .or. topparent.class() = "browse" then
current_window = topparent.name()
'remove the current window from the list
open_windows = word_subtract(open_windows,current_window,crlf())
end if
end if
'generate the xbasic to close all of the open windows (excepting the current window)....................
if open_windows <> "" then
dim cmd_close as c
cmd_close = *for_each(x,x+".close()" , open_windows)
''now execute the xbasic
cmd_result = evaluate_template(cmd_close)
if cmd_result <> "" then
ui_msg_box("Error",cmd_result)
goto skip_rest_close_open_windows
end if
end if
if is_object(topparent.this) then
if topparent.class() = "form" .or. topparent.class() = "browse" then
dim q_msg as n
q_msg = ui_msg_box("Notice",msg,UI_ATTENTION_SYMBOL+UI_OK_CANCEL)
if q_msg = ui_ok_selected then
dim topparent_name as c
dim cmd as c
dim condition as c
dim open_sessions as c
open_sessions = session_enum()
dim open_session_count as n
open_session_count = line_count(open_sessions)
if topparent.class() = "form" then
cmd = "dim tempP as p; tempP = form.view(" + quote(topparent.name(1)+"@" + topparent.Dictionary_Get(1))+")"
else
cmd = "dim tempP as p; tempP = browse.view(" +quote( topparent.name(1)+"@" + topparent.Dictionary_Get(1))+")"
end if
if a5_IsMaximized() = .t. then
cmd = cmd + crlf() +"xbasic_wait_for_idle()" + crlf() + "tempP.maximize()" + crlf()
end if
'when the number of sessions is one less than the number before the layout is closed then
'the session that the form/browse was based on has been closed, and it is safe to run the
'command.
condition = "line_count(session_enum()) = " + (open_session_count - 1 )
cmd = cmd_initial + crlf() + cmd
'is the control panel hidden? if so then you have to temporarily show it, or else the database will close
'after you close this form.
if ControlPanel.IsVisible() = .f. then
ControlPanel.Minimize()
cmd = cmd + crlf() + "controlpanel.hide()"
if a5_IsMaximized() then
topparent.restore()
end if
end if
on_condition(condition,cmd)
topparent.close()
end if
else 'topparent is an object, but it is not a form or browse
cmd_result = evaluate_template(cmd_initial)
if cmd_result <> "" then
ui_msg_box("Error",cmd_result)
end if
end if
else ' topparent is not an object
cmd_result = evaluate_template(cmd_initial)
if cmd_result <> "" then
ui_msg_box("Error",cmd_result)
end if
end if
skip_rest_close_open_windows:
Comment