Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remove folder history from "Look Up Referece" in "Code Reference" 4

Status
Not open for further replies.

Rajesh Karunakaran

Programmer
Sep 29, 2016
549
MU
Hi Team!

In VFP 9, we have "Code Reference" under "Tools". When you click search, it displays the "Look Up Reference" dialog where we mention all search parameters. There if the Scope is Folder, you can mention a folder in 'Look In'. The combo box attached to 'Look In' shows all those folders that were mentioned in previous searches, i.e. it saves the history.

Is there a way to remove/delete all those previous folder list that were used in previous searches?
In which VFP system table, these info are saved?

Thanks in advance
Rajesh
 
Hi Tore,

My problem is not getting a better one than Code Reference, but to remove the folder history it has currently.

Also, reference searches I do are simple. However, I will have a look in GoFish.
Thanks.
 
Rajesh,

The data is stored in the Resource file, under "FOXREF" Id, empty Name. The array that stores the list is FOXREF_FOLDER_MRU. To remove the history, you'll have to RESTORE the data, clear the array, and SAVE back the FOXREF_* data (probably having to set the checksum, also).
 
Not sure what you mean with folder history. If you want to remove the search history you can set a checkbox option when searching: "Overwrite previous results". That does not only remove previous results of tht search (that's done anyway, if you repeat a search, after you replaced something) it clears the whole search history.

Bye, Olaf.

Olaf Doschke Software Engineering
 
I can confirm what Altopes said. I've just doen a couple of sample searches in Code References, using different folders. I can see a record in FoxUser that has ID = FOXREF and an empty name. The Data memo contains the names of the folders that I searched.

However, this is binary data, so it might be difficult to edit or delete parts of it. You could try deleting the entire record, which will probably clear all the Code References history. But you had better back it up first.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Mike said:
However, this is binary data, so it might be difficult to edit or delete parts of it.

The process would be something like this (warning! completely untested):
Code:
RESTORE FROM MEMO data ADDITIVE
STORE "" TO FOXREF_FOLDER_MRU
SAVE TO MEMO data ALL LIKE FOXREF_*

Don't know about the effect it would have on resource entry availability considering Ckval is not updated, but Rajesh may be willing to try (on a backup, of course, as the cleaning code itself).
 
Dear Atlopes and Mike,

Both of you got exactly what I wanted.
Thank you both. I did it and saw that the history is gone!

Atlopes had a clear and accurate technical explanation, Great!,
while, you Mike, in your usual way, made it very simple and to the point!
Liked it!

Thanks
Rajesh
 
I think I now know what you mean. The list of folders dropping down from "Look in".

The RESTORE FROM MEMO DATA of the corresponding Foxuser.dbf record always only holds 10 elements in an array FOXREF_FOLDER_MRU. Not much to clear, the easy and safe way without risking to store back too much further variables obviously is just picking 10 folders to override the MRU list.

Yes, you can RESTORE FROM MEMO DATA, edit variables, eg in the debugger locals window or by assignment commands and then store your changes back with SAVE TO MEMO DATA, but that'll save whatever other variables you have defined.

This is code from foxref.pjx of xsource.zip:

Code:
	* Save preferences to FoxPro Resource file
	FUNCTION SavePrefs()
		LOCAL nSelect
		LOCAL lSuccess
		LOCAL nMemoWidth
		LOCAL nCnt
		LOCAL cData
		LOCAL i
		LOCAL oOptionCollection
		LOCAL ARRAY aFileList[1]
		LOCAL ARRAY FOXREF_OPTIONS[1]
		LOCAL ARRAY FOXREF_LOOKFOR_MRU[10]
		LOCAL ARRAY FOXREF_FOLDER_MRU[10]
		LOCAL ARRAY FOXREF_FILETYPES_MRU[10]

		IF !(SET("RESOURCE") == "ON")
			RETURN .F.
		ENDIF

		=ACOPY(THIS.aLookForMRU, FOXREF_LOOKFOR_MRU)
		=ACOPY(THIS.aReplaceMRU, FOXREF_REPLACE_MRU)
		=ACOPY(THIS.aFolderMRU, FOXREF_FOLDER_MRU)
		=ACOPY(THIS.aFileTypesMRU, FOXREF_FILETYPES_MRU)

		oOptionCollection = CREATEOBJECT("Collection")
		* Add any properties you want to save to
		* the resource file to this collection
		WITH oOptionCollection
			.Add(THIS.Comments, "Comments")
			.Add(THIS.MatchCase, "MatchCase")
			.Add(THIS.WholeWordsOnly, "WholeWordsOnly")
			.Add(THIS.Wildcards, "Wildcards")
			.Add(THIS.ProjectHomeDir, "ProjectHomeDir")
			.Add(THIS.SubFolders, "SubFolders")
			.Add(THIS.OverwritePrior, "OverwritePrior")
			.Add(THIS.FileTypes, "FileTypes")
			.Add(THIS.IncludeDefTable, "IncludeDefTable")
			.Add(THIS.CodeOnly, "CodeOnly")
			.Add(THIS.FormProperties, "FormProperties")
			.Add(THIS.AutoProjectHomeDir, "AutoProjectHomeDir")
			.Add(THIS.ConfirmReplace, "ConfirmReplace")
			.Add(THIS.BackupOnReplace, "BackupOnReplace")
			.Add(THIS.DisplayReplaceLog, "DisplayReplaceLog")
			.Add(THIS.PreserveCase, "PreserveCase")
			.Add(THIS.BackupStyle, "BackupStyle")
			.Add(THIS.ShowRefsPerLine, "ShowRefsPerLine")
			.Add(THIS.ShowFileTypeHistory, "ShowFileTypeHistory")
			.Add(THIS.ShowDistinctMethodLine, "ShowDistinctMethodLine")
			.Add(THIS.SortMostRecentFirst, "SortMostRecentFirst")
			.Add(THIS.FontString, "FontString")
			.Add(THIS.FoxRefDirectory, "FoxRefDirectory")
		ENDWITH

		DIMENSION FOXREF_OPTIONS[MAX(oOptionCollection.Count, 1), 2]
		FOR i = 1 TO oOptionCollection.Count
			FOXREF_OPTIONS[m.i, 1] = oOptionCollection.GetKey(m.i)
			FOXREF_OPTIONS[m.i, 2] = oOptionCollection.Item(m.i)
		ENDFOR


		nSelect = SELECT()
		
		lSuccess = .F.

  		* make sure Resource file exists and is not read-only
  		TRY
	  		nCnt = ADIR(aFileList, SYS(2005))
	  	CATCH
	  		nCnt = 0
	  	ENDTRY
	  		
		IF nCnt > 0 AND ATCC('R', aFileList[1, 5]) == 0
			IF !USED("FoxResource")
				USE (SYS(2005)) IN 0 SHARED AGAIN ALIAS FoxResource
			ENDIF
			IF USED("FoxResource") AND !ISREADONLY("FoxResource")
				nMemoWidth = SET('MEMOWIDTH')
				SET MEMOWIDTH TO 255

				SELECT FoxResource
				LOCATE FOR UPPER(ALLTRIM(type)) == "PREFW" AND UPPER(ALLTRIM(id)) == RESOURCE_ID AND EMPTY(name)
				IF !FOUND()
					APPEND BLANK IN FoxResource
					REPLACE ; 
					  Type WITH "PREFW", ;
					  ID WITH RESOURCE_ID, ;
					  ReadOnly WITH .F. ;
					 IN FoxResource
				ENDIF

				IF !FoxResource.ReadOnly
					SAVE TO MEMO Data ALL LIKE FOXREF_*

					REPLACE ;
					  Updated WITH DATE(), ;
					  ckval WITH VAL(SYS(2007, FoxResource.Data)) ;
					 IN FoxResource

					lSuccess = .T.
				ENDIF
				SET MEMOWIDTH TO (nMemoWidth)
			
				USE IN FoxResource
			ENDIF
		ENDIF

		SELECT (nSelect)
		
		RETURN lSuccess
	ENDFUNC

From that, you could at least take to store back changes with the line
Code:
SAVE TO MEMO Data ALL LIKE FOXREF_*

Bye, Olaf.


Olaf Doschke Software Engineering
 
Hi Mike,

Mike said:
Can we now ask why you want to do this?

We keep many folders containing codes for production development and many other for trial runs sets. After many references in all these, it becomes a long list which sometimes we don't need anymore. In fact, this list was there since long. So, wanted to clear everything.

But, as Olaf said above, I am not sure if it was only 10 in the list. Now, as it has already gone, no way to verify it!

Thank you all,
Rajesh
 
No need to verify, this is 1:1 code of the Code References feature and it has arrays dimensioned to fixed length 10 elements, if you use less than 10 directories elementsare stored empty, if you have 10 and add an 11th the oldest is reused.

You find the source code project in xsource.zip. If not you find a download still officially from MS: or at VFPX:
It's in use anyway and the code simply shows it only memorizes several things 10 MRU slots. Might look cluttered enough, but there is that limit, you'll never overflow that.

Bye, Olaf.

Olaf Doschke Software Engineering
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top