''Counting the number of dialogs within a project and reporting the results.
Sub Main
	' output string
	Dim msg As String

	' get active project
	Dim prj As PslProject
	Set prj = PSL.ActiveProject
	If prj Is Nothing Then
		MsgBox "Please open a project"
		Exit Sub
	End If

	' report date and project
	msg = "Date:    " & Now & vbCrLf & "Project: " & prj.Name & vbCrLf & vbCrLf

	' get number of modules
	Dim srcfiles As Integer
	srccount = prj.SourceLists.Count
	Dim totalDialogs As Integer
	totalDialogs = 0

	' walk thru all modules
	For j = 1 To srccount

		' get source list
    	Dim src As PslSourceList
    	Set src = prj.SourceLists.Item(j)

		' get number of string in source list
		Dim count As Integer
		count = src.StringCount

		' initialization
		Dim curResNumber As Integer
		curResNumber = -1

		Dim dialogCount As Integer
		dialogCount = 0

		' walk thru all strings in source list
		Dim i As Integer
		For i = 1 To count
			Dim s As PslSourceString
			Set	s = src.String(i)

			' check source list string type for "Dialog"
			If s.ResType = "Dialog" Then

				' check if we have reached a new dialog
				If curResNumber = -1 Or curResNumber <> s.Resource.Number Then

					' count the dialog
					dialogCount = dialogCount + 1
					curResNumber = s.Resource.Number
				End If
			End If
		Next i

		' report number of dialogs in module
		msg = msg & dialogCount & " dialogs In Module " & src.Title & vbCrLf
		' count total number of dialogs
		totalDialogs = totalDialogs + dialogCount
	Next j

	' report total number of dialogs
	msg = msg & vbCrLf & "Total number of dialogs: " & totalDialogs

	' create report dialog
	Begin Dialog UserDialog 400,203,"PASSOLO Dialog Counter" ' %GRID:10,7,1,1
		PushButton 20,175,180,21,"Copy to Clipboard",.Copy
		OKButton 300,175,90,21
		TextBox 20,14,360,147,.Text,1
	End Dialog
	Dim dlg As UserDialog

	' move report string into dialog
	dlg.Text$ = msg

	' check if clipboard button was pressed
	If Dialog(dlg) = 1 Then
		' move report to clipboard
		Clipboard msg
	End  If
End Sub
