From the Query by Form, Query Genie and Query by Expression dialogs the end user can save the queries they create. To delete these queries one must go to the Operations tab on the Control Panel. This is a issue if you are using the runtime or wish to restrict users access to the control panel.
This is where the following script comes in. Run it from a button on a form or add it to the Script Favorites List on the Scripts menu option. It will give the end user an easy way to delete unneeded saved Queries that may be cluttering up the the list they see when they retrieve Queries.
This is where the following script comes in. Run it from a button on a form or add it to the Script Favorites List on the Scripts menu option. It will give the end user an easy way to delete unneeded saved Queries that may be cluttering up the the list they see when they retrieve Queries.
Code:
'Date Created: 03-Apr-2014 12:41:37 PM 'Last Updated: 03-Apr-2014 03:10:05 PM 'Created By : Paul Verboom 'Updated By : Paul Verboom '------------ 'zQueryDelete '------------ 'Script to delete selected Queries defined for table of set 'current form or browse is defined for ' 'xBasic commands used 'A5_get_operations("Query","b-patients") ---> Returns a list of operations 'object_operation("query","needs review","","delete") ---> Deletes named Query 'Object command came from following MsgBoard Post 'http://msgboard.alphasoftware.com/alphaforum/showthread.php?70278-How-to-delete-a-custom-query&highlight=delete+operation 'Title for all messages DIM DialogTtl as C = "Delete User Queries (zQueryDelete)" '------------------------------------------------ '// Verify Script is run from a form or browse -- '------------------------------------------------ DIM RunFromFB as L = .F. IF is_object(topparent.this) THEN 'is top parent valid, no if script run in editor IF topparent.Class() = "form" .or. topparent.class() = "browse" THEN RunFromFB = .T. END IF END IF IF .not. RunFromFB 'Not run from form or browse error out error_generate("Script Must be run from From or Browse") end end if '---------------------------------- '// Get the current table of set -- '---------------------------------- DIM Ptr as P 'Only Queries for current form or browse can DIm FileName as C ' be deleted Ptr = set.current() 'Find out what the name of that form or browse is FileName = Ptr.filename_get() If isnull(FileName) Ptr = topparent.Table_Get() FileName = Ptr.filename_get() end if If isnull(FileName) error_generate("Unable to determine current Set or Table") end end if '----------------------------------------------- '// Put up Dialog to select Queries to delete -- '----------------------------------------------- DIM QueryList as C 'Get list of Queries for this Table/Set QueryList = A5_get_operations("Query",FileName) 'List is used dirrectly by Dialog no arrays needed IF isnull(QueryList) error_generate("No User defined Queries for this Screen") end end if DIM Result as C 'Result from Dialog must be Proceed to do delete DIM QuerySelected as C 'List of entries selected by user Dialog =<<%dlg% {region} {wrap=40}Select the user defined Queries to delete.; ; [%m%.40,10QuerySelected^#QueryList]; {endregion}; {line=1,0}; {region} <*15&Proceed!Proceed> <15&Cancel!CANCEL> {endregion}; %dlg% Result = ui_dlg_box(DialogTtl,Dialog) 'present Dialog if Result <>"Proceed" then 'do we proceed end end if '--------------------------------- '// Delete the selected Queries -- '--------------------------------- DIM Query for each Query in QuerySelected 'Go through each query in list to delete '! for debugging '!ui_msg_box("About to delete",Query) object_operation("query",Query,"","delete") next