Project Functions
SearchForRefs (hbuf, word, fTouchFiles)
Searches for references to the word string in word throughout the whole project. Each line that contains word is appended to the buffer hbuf. If fTouchFiles is TRUE, then each file that contains word will have its last-modified time stamp set to the current time.
This function is similar to the "Lookup References" command. Word can contain more than one word, but this function is much faster if it is a single word.
This example creates a new search results file and searches for references.
macro LookupRefs (symbol)
{ hbuf = NewBuf("Results") // create output buffer if (hbuf == 0) stop
SearchForRefs(hbuf, symbol, 0)
SetCurrentBuf(hbuf) // put buffer in a window
}
SearchInBuf (hbuf, pattern, lnStart, ichStart, fMatchCase, fRegExp, fWholeWordsOnly)
Searches for pattern in the buffer hbuf. The search starts at line number lnStart and character index ichFirst.
SearchInBuf returns a Sel record which spans the matching text. If nothing is found, then an empty string is returned. See GetWndSel for a description of the Sel record.
If fMatchCase, then the search is case sensitive.
If fRegExpr, then the pattern contains a regular expression. Otherwise, the pattern is a simple string.
If fWholeWordsOnly then only whole words will cause a match.
SetSourceLink (hbufSource, lnSource, target_file, lnTarget)
Creates a new source link. The link source buffer is hbufSource. The link source line number is lnSource. The link target file is given as a path string in target_file. The link target line number is lnTarget.
Returns True if successful, or False if not. Target_file does not have to exist. The operation will not fail just because target_file does not exist. Also, target_file does not need to be open.
For consistent results, target_file should contain a fully qualified path name for a file. However, you may pass a simple file spec to this function and it will expand target_file based on what files are included in the current project and on the project symbol path.
Source Links are destroyed when the source buffer closes, or when the source line is deleted.
Project Functions
Project functions allow you to open and close projects, and get project information.
AddConditionVariable(hprj, szName, szValue)
Adds a new conditional parsing variable used to evaluation conditional statements such as #if while parsing code.
Hprj is a handle to the project. If hprj is hNil, then the new variable is added to the global condition list.
The name of the variable is given in szName, and the value is given in szValue
There are two condition lists: the global list and the project-specific list. When you open a project, the two lists are merged, with the project-specific list taking precedence over entries in the global list.
See also “DeleteConditionVariable(hprj, szName)” on page 406.. See “Conditional Parsing” on page 58.
Source Insight 4 User Guide 405
Project Functions
AddFileToProj(hprj, filename)
Adds the given filename to the project hprj.
CloseProj (hprj)
Closes the project hprj.
DeleteConditionVariable(hprj, szName)
Deletes a new conditional parsing variable used to evaluation conditional statements such as #if while parsing code.
Hprj is a handle to the project. If hprj is hNil, then the variable is deleted from the global condition list.
The name of the variable is given in szName.
There are two condition lists: the global list and the project-specific list. When you open a project, the two lists are merged, with the project-specific list taking precedence over entries in the global list.
See also “AddConditionVariable(hprj, szName, szValue)” on page 405.. See “Conditional Parsing” on page 58.
DeleteProj (proj_name)
Delete the project named in proj_name. If that project is currently open, then the user is asked if they want to close it first. If the user does not close the project, then the project is not deleted.
EmptyProj ()
Empties the project by removing all files from the project. The actual files themselves are not affected.
Returns True if successful, or False if errors.
GetCurrentProj ()
Returns the handle (hprj) of the currently open project. Source Insight only allows the user to open a single project at a time; however from the macro language, more than one project can be open.
GetProjDir (hprj)
Returns the source directory path of the project hprj.
GetProjFileCount (hprj)
Returns the number of files added to the project hprj.
GetProjFileName (hprj, ifile)
Returns the name of the project file associated with index ifile in the project hprj.
Each project has an index of project files, sorted by file name. GetProjFileName maps an index to a file name.
File index values start at zero and go up to the count returned by GetProjFileCount.
This example interates through all project files: ifileMax = GetProjFileCount (hprj) ifile = 0 while (ifile < ifileMax)
{ filename = GetProjFileName (hprj, ifile)
..
ifile = ifile + 1
}
GetProjName (hprj)
Returns the name of the project hprj. The name contains the full path of the project file.
406 Source Insight 4 User Guide
Project Functions
GetProjSymCount (hprj)
Returns the number of symbols in the project hprj.
GetProjSymLocation (hprj, isym)
Returns symbol location information in a Symbol record for the symbol associated with index isym in the
project hprj. See “Symbol Record” on page 382.
Each project has an index of symbols, sorted by symbol name. GetProjSymLocation maps an index to a symbol Symbol record. Symbol index values start at zero and go up to the count returned by GetProjSymCount.
You can call JumpToLocation to move to the Symbol record returned by GetProjSymLocation.
See GetSymbolLocation for more information on Symbol records.
GetProjSymName (hprj, isym)
Returns the name of the symbol associated with index isym in the project hprj.
Each project has an index of symbols, sorted by symbol name. GetProjSymName maps an index to a symbol name. Symbol index values start at zero and go up to the count returned by GetProjSymCount minus one.
This example interates through all project symbols: isymMax = GetProjSymCount (hprj) isym = 0 while (isym < isymMax)
{ symname = GetProjSymName (hprj, isym)
..
isym = isym + 1
}
NewProj (proj_name)
Creates a new project and returns a project handle (hprj), or returns hNil if errors.
OpenProj (proj_name)
Opens the project named proj_name and returns a project handle (hprj), or hNil if errors.
RemoveFileFromProj(hprj, filename)
Removes the given filename from the project hprj. The file on disk is not altered or deleted.
SyncProj (hprj)
Synchronizes the project hprj. All files in the project are checked for external changes and Source Insight's symbol database is updated incrementally for files that have changed.
SyncProjEx(hprj, fAddNewFiles, fForceAll, fSupressWarnings)
Synchronizes the project hprj. All files in the project are checked for external changes and Source Insight's symbol database is updated incrementally for files that have changed.
New files are automatically added to the project if fAddNewFiles is True. Only file names that match document types defined in the Document Options command are added.
If fForceAll, then each file in the project is re-synchronized, regardless of its time stamp.
If fSuppressWarnings, then Source Insight will not issue warnings if it has errors opening files.
Source Insight 4 User Guide 407