Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add read text file function #8

Merged
merged 1 commit into from
May 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions wsh/chcl3.vbs
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")

Function ReadTextFile(Path)
Dim Buffer
Set fh = fso.OpenTextFile(Path, 1)
Buffer = fh.ReadAll()
fh.Close
Set fh = Nothing
ReadTextFile = Buffer
End Function

Function DisplayLicense()
Dim LicenseText
LicenseText = ReadTextFile("..\LICENSE")

Set fh = fso.OpenTextFile("..\LICENSE", 1)
strFileText = fh.ReadAll()
fh.Close
Set fh = Nothing
'Reflow the text by removing unwanted new line characters. Keep the empty
'line separating paragraphs.
LicenseText = Replace(Replace(Replace(LicenseText, vbCrLf & vbCrLf, "~~~"), vbCrLf, " "), "~~~", vbCrLf & vbCrLf)

LicenseText = Replace(Replace(Replace(strFileText, vbCrLf & vbCrLf, "~~~"), vbCrLf, " "), "~~~", vbCrLf & vbCrLf)
LicenseText = LicenseText & vbCrLf & "Click No to exit now or Yes to accept the license." & vbCrLf
DisplayLicense = MsgBox(LicenseText, vbYesNo + vbInformation + vbDefaultButton2, "License Agreement")
End Function
Expand Down