Option Explicit

Public fso As New FileSystemObject

' Unit Testing Framework, based on from
' Example: AssertEqual "5 + 6 should equal 11", 5 + 6, 112
Public Sub AssertEqual(name, v1, v2)
    If v1 <> v2 Then MsgBox name & ":" & vbCrLf & v1 & vbCrLf & "<>" & vbCrLf & v2, vbInformation, "#epicfail": Stop
End Sub

' Returns the My Documents folder.  Returned path has no trailing backslash
Public Function GetMyDocumentsLibrary() As String
    GetMyDocumentsLibrary = CreateObject("WScript.Shell").SpecialFolders("mydocuments")
End Function

Private Sub TestGetMyDocumentsLibrary()
    Assert "TestGetMyDocumentsLibrary", GetMyDocumentsLibrary() = "C:\Documents"
End Sub

Public Sub ForEachFile(ByVal proc As String, ByVal fs As Files)
    Dim f As File: For Each f In fs
        Application.Run proc, f
End Sub

Public Sub Log(ByVal s As String)
    Const ForAppending = 8
    Const cFileName = "c:\log.txt"
    Dim ts As TextStream

    If fso.FileExists(cFileName) Then
        Set ts = fso.OpenTextFile(cFileName, ForAppending)
        Set ts = fso.CreateTextFile(cFileName)
    End If
    ts.WriteLine s
End Sub

Private Sub Test()
End Sub

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.