Skip to content

Commit e48f70b

Browse files
authored
.NET 5.0 以降対応のために FIleOpen() や PrintLine() の置き換え
文字コードも固定
1 parent 386bc8a commit e48f70b

File tree

4 files changed

+135
-137
lines changed

4 files changed

+135
-137
lines changed

frmWindowViewer.vb

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ Friend Class frmWindowViewer
4040
Dim i As Integer
4141
Dim lngFFile As Integer
4242
Dim lngTemp As Integer
43-
43+
Dim swSrmWtr As System.IO.StreamWriter = Nothing
44+
4445
ReDim g_Viewer(UBound(m_LocalViewer))
4546

4647
If lstViewer.SelectedIndex <> -1 Then
@@ -63,72 +64,72 @@ Friend Class frmWindowViewer
6364
If lngTemp < 0 Then lngTemp = 0
6465

6566
Call frmMain.cboViewer.Items.Clear()
66-
67-
lngFFile = FreeFile
68-
69-
FileOpen(lngFFile, g_strAppDir & "bmse_viewer.ini", OpenMode.Output)
70-
67+
68+
lngFFile = FreeFile()
69+
70+
swSrmWtr = My.Computer.FileSystem.OpenTextFileWriter(g_strAppDir & "bmse_viewer.ini", False, System.Text.Encoding.GetEncoding("UTF-8"))
71+
7172
For i = 1 To UBound(m_LocalViewer)
72-
73+
7374
With m_LocalViewer(i)
74-
75-
PrintLine(lngFFile, .strAppName)
76-
PrintLine(lngFFile, .strAppPath)
77-
PrintLine(lngFFile, .strArgAll)
78-
PrintLine(lngFFile, .strArgPlay)
79-
PrintLine(lngFFile, .strArgStop)
80-
PrintLine(lngFFile)
81-
75+
76+
swSrmWtr.WriteLine(.strAppName)
77+
swSrmWtr.WriteLine(.strAppPath)
78+
swSrmWtr.WriteLine(.strArgAll)
79+
swSrmWtr.WriteLine(.strArgPlay)
80+
swSrmWtr.WriteLine(.strArgStop)
81+
swSrmWtr.WriteLine()
82+
8283
Call frmMain.cboViewer.Items.Add(.strAppName)
83-
84+
8485
g_Viewer(i).strAppName = .strAppName
8586
g_Viewer(i).strAppPath = .strAppPath
8687
g_Viewer(i).strArgAll = .strArgAll
8788
g_Viewer(i).strArgPlay = .strArgPlay
8889
g_Viewer(i).strArgStop = .strArgStop
89-
90+
9091
End With
91-
92+
9293
Next i
93-
94-
FileClose(lngFFile)
95-
94+
95+
swSrmWtr.Close()
96+
9697
With frmMain
97-
98+
9899
If .cboViewer.Items.Count = 0 Then
99-
100+
100101
.tlbMenu.Items.Item("PlayAll").Enabled = False
101102
.tlbMenu.Items.Item("Play").Enabled = False
102-
.tlbMenu.Items.Item("_Stop").Enabled = False
103-
.mnuToolsPlayAll.Enabled = False
103+
.tlbMenu.Items.Item("_Stop").Enabled = False
104+
.mnuToolsPlayAll.Enabled = False
104105
.mnuToolsPlay.Enabled = False
105106
.mnuToolsPlayStop.Enabled = False
106107
.cboViewer.Enabled = False
107-
108+
108109
Else
109-
110+
110111
.tlbMenu.Items.Item("PlayAll").Enabled = True
111112
.tlbMenu.Items.Item("Play").Enabled = True
112-
.tlbMenu.Items.Item("_Stop").Enabled = True
113-
.mnuToolsPlayAll.Enabled = True
113+
.tlbMenu.Items.Item("_Stop").Enabled = True
114+
.mnuToolsPlayAll.Enabled = True
114115
.mnuToolsPlay.Enabled = True
115116
.mnuToolsPlayStop.Enabled = True
116117
.cboViewer.Enabled = True
117-
118+
118119
If frmMain.cboViewer.Items.Count > lngTemp Then
119-
120+
120121
frmMain.cboViewer.SelectedIndex = lngTemp
121-
122+
122123
Else
123-
124+
124125
frmMain.cboViewer.SelectedIndex = 0
125-
126+
126127
End If
127-
128+
128129
End If
129-
130+
130131
End With
131-
132+
132133
Call Me.Close()
133134

134135
End Sub

modInput.vb

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -270,30 +270,29 @@ Err_Renamed:
270270
Dim i As Integer
271271
Dim strArray() As String
272272
Dim strTemp As String
273-
Dim lngFFile As Integer
274-
275-
lngFFile = FreeFile()
273+
Dim srSrmRdr As System.IO.StreamReader = Nothing
274+
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance)
276275

277-
FileOpen(lngFFile, g_BMS.strDir & g_BMS.strFileName, OpenMode.Input)
276+
srSrmRdr = My.Computer.FileSystem.OpenTextFileReader(g_BMS.strDir & g_BMS.strFileName, System.Text.Encoding.GetEncoding("Shift_JIS"))
277+
278+
Do Until (srSrmRdr.Peek = -1)
279+
280+
'System.Windows.Forms.Application.DoEvents()
281+
282+
strTemp = srSrmRdr.ReadLine
278283

279-
Do While Not EOF(lngFFile)
280-
281-
System.Windows.Forms.Application.DoEvents()
282-
283-
strTemp = LineInput(lngFFile)
284-
285284
strArray = Split(Replace(Replace(strTemp, vbCr, vbCrLf), vbLf, vbCrLf), vbCrLf)
286-
285+
287286
For i = 0 To UBound(strArray)
288-
287+
289288
If Left(strArray(i), 1) = "#" Then Call LoadBMSLine(strArray(i))
290-
289+
291290
Next i
292-
293-
Loop
294-
295-
FileClose(lngFFile)
296-
291+
292+
Loop
293+
294+
srSrmRdr.Close()
295+
297296
ReDim Preserve g_Obj(UBound(g_Obj))
298297

299298
For i = 0 To UBound(g_Obj) - 1

modMain.vb

Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,8 @@ Module modMain
385385
Dim i As Integer
386386
Dim strTemp As String
387387
Dim intTemp As Integer
388-
Dim lngFFile As Integer
388+
Dim srSrmRdr As System.IO.StreamReader = Nothing
389+
Dim swSrmWtr As System.IO.StreamWriter = Nothing
389390

390391
If Right(My.Application.Info.DirectoryPath, 1) = "\" Then
391392

@@ -421,46 +422,43 @@ Module modMain
421422
'UPGRADE_WARNING: Dir に新しい動作が指定されています。 詳細については、'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"' をクリックしてください。
422423
If Dir(g_strAppDir & "bmse_viewer.ini", FileAttribute.Normal) = vbNullString Then
423424

424-
lngFFile = FreeFile()
425-
426-
FileOpen(lngFFile, g_strAppDir & "bmse_viewer.ini", OpenMode.Output)
427-
428-
PrintLine(lngFFile, "mBMplay")
429-
PrintLine(lngFFile, "..\mBMplay\mBMplay.exe")
430-
PrintLine(lngFFile, "<filename>")
431-
PrintLine(lngFFile, "-s <measure> <filename>")
432-
PrintLine(lngFFile, "-t")
433-
PrintLine(lngFFile)
434-
PrintLine(lngFFile, "uBMplay")
435-
PrintLine(lngFFile, "..\uBMplay\uBMplay.exe")
436-
PrintLine(lngFFile, "-P -N0 <filename>")
437-
PrintLine(lngFFile, "-P -N<measure> <filename>")
438-
PrintLine(lngFFile, "-S")
439-
PrintLine(lngFFile)
440-
PrintLine(lngFFile, "beatoraja")
441-
PrintLine(lngFFile, "..\beatoraja-jre\beatoraja.exe")
442-
PrintLine(lngFFile, "-a <filename>")
443-
PrintLine(lngFFile, "-p <filename>")
444-
PrintLine(lngFFile, "")
445-
PrintLine(lngFFile)
446-
PrintLine(lngFFile, "LR2")
447-
PrintLine(lngFFile, "..\LR2\LR2body.exe")
448-
PrintLine(lngFFile, "-a <filename>")
449-
PrintLine(lngFFile, "-a <filename>")
450-
PrintLine(lngFFile, "")
451-
452-
FileClose(lngFFile)
425+
swSrmWtr = My.Computer.FileSystem.OpenTextFileWriter(g_strAppDir & "bmse_viewer.ini", False, System.Text.Encoding.GetEncoding("UTF-8"))
426+
427+
swSrmWtr.WriteLine("mBMplay")
428+
swSrmWtr.WriteLine("..\mBMplay\mBMplay.exe")
429+
swSrmWtr.WriteLine("<filename>")
430+
swSrmWtr.WriteLine("-s <measure> <filename>")
431+
swSrmWtr.WriteLine("-t")
432+
swSrmWtr.WriteLine()
433+
swSrmWtr.WriteLine("uBMplay")
434+
swSrmWtr.WriteLine("..\uBMplay\uBMplay.exe")
435+
swSrmWtr.WriteLine("-P -N0 <filename>")
436+
swSrmWtr.WriteLine("-P -N<measure> <filename>")
437+
swSrmWtr.WriteLine("-S")
438+
swSrmWtr.WriteLine()
439+
swSrmWtr.WriteLine("beatoraja")
440+
swSrmWtr.WriteLine("..\beatoraja-jre\beatoraja.exe")
441+
swSrmWtr.WriteLine("-a <filename>")
442+
swSrmWtr.WriteLine("-p <filename>")
443+
swSrmWtr.WriteLine("")
444+
swSrmWtr.WriteLine()
445+
swSrmWtr.WriteLine("LR2")
446+
swSrmWtr.WriteLine("..\LR2\LR2body.exe")
447+
swSrmWtr.WriteLine("-a <filename>")
448+
swSrmWtr.WriteLine("-a <filename>")
449+
swSrmWtr.WriteLine("")
450+
451+
swSrmWtr.Close()
453452

454453
End If
455454

456455
i = 0
457-
lngFFile = FreeFile()
458456

459-
FileOpen(lngFFile, g_strAppDir & "bmse_viewer.ini", OpenMode.Input)
457+
srSrmRdr = My.Computer.FileSystem.OpenTextFileReader(g_strAppDir & "bmse_viewer.ini", System.Text.Encoding.GetEncoding("UTF-8"))
460458

461-
Do While Not EOF(lngFFile)
459+
Do Until (srSrmRdr.Peek = -1)
462460

463-
strTemp = LineInput(lngFFile)
461+
strTemp = srSrmRdr.ReadLine
464462

465463
Select Case i Mod 6
466464

@@ -495,7 +493,7 @@ Module modMain
495493

496494
Loop
497495

498-
FileClose(lngFFile)
496+
srSrmRdr.Close()
499497

500498
ReDim Preserve g_Viewer(frmMain.cboViewer.Items.Count)
501499

@@ -827,14 +825,15 @@ Module modMain
827825
Public Sub DebugOutput(ByVal lngErrNum As Integer, ByRef strErrDescription As String, ByRef strErrProcedure As String, Optional ByVal blnCleanUp As Boolean = False)
828826
Dim lngFFile As Integer
829827
Dim strError As String = ""
828+
Dim swSrmWtr As System.IO.StreamWriter = Nothing
830829

831830
lngFFile = FreeFile()
832831

833-
FileOpen(lngFFile, g_strAppDir & "error.txt", OpenMode.Append)
832+
swSrmWtr = My.Computer.FileSystem.OpenTextFileWriter(g_strAppDir & "error.txt", True, System.Text.Encoding.GetEncoding("UTF-8"))
834833

835-
PrintLine(lngFFile, Today & TimeOfDay & "ErrorNo." & lngErrNum & " " & strErrDescription & "@" & strErrProcedure & "/BMSE_" & My.Application.Info.Version.Major & "." & My.Application.Info.Version.Minor & "." & My.Application.Info.Version.Revision)
834+
swSrmWtr.WriteLine(Today & TimeOfDay & "ErrorNo." & lngErrNum & " " & strErrDescription & "@" & strErrProcedure & "/BMSE_" & My.Application.Info.Version.Major & "." & My.Application.Info.Version.Minor & "." & My.Application.Info.Version.Revision)
836835

837-
FileClose(lngFFile)
836+
swSrmWtr.Close()
838837

839838
strError = strError & "ErrorNo." & lngErrNum & " " & strErrDescription & "@" & strErrProcedure
840839

0 commit comments

Comments
 (0)