@@ -76,6 +76,7 @@ Private Function Process(vArgs As Variant) As Long
76
76
Dim uPapers() As UcsPaperInfoType
77
77
Dim sText As String
78
78
79
+ On Error GoTo EH
79
80
Set m_oOpt = GetOpt(vArgs, "printer:orientation:paper:margins:o" )
80
81
If Not m_oOpt.Item("-nologo" ) And Not m_oOpt.Item("-q" ) Then
81
82
ConsoleError App.ProductName &
" " & App.Major &
"." & App.Minor &
" (c) 2018 by [email protected] " & vbCrLf
@@ -98,7 +99,7 @@ Private Function Process(vArgs As Variant) As Long
98
99
" -q in quiet operation outputs only errors" & vbCrLf & _
99
100
" -nologo suppress startup banner" & vbCrLf
100
101
If m_oOpt.Item("#arg" ) < 0 Then
101
- Process = 100
102
+ Process = 1
102
103
End If
103
104
GoTo QH
104
105
End If
@@ -120,6 +121,11 @@ Private Function Process(vArgs As Variant) As Long
120
121
End If
121
122
End If
122
123
Next
124
+ If cFiles.Count = 0 Then
125
+ ConsoleError "No input files found" & vbCrLf
126
+ Process = 1
127
+ GoTo QH
128
+ End If
123
129
ReDim vInputFiles(0 To cFiles.Count - 1 ) As String
124
130
For lIdx = 1 To cFiles.Count
125
131
vInputFiles(lIdx - 1 ) = cFiles.Item(lIdx)
@@ -147,10 +153,10 @@ Private Function Process(vArgs As Variant) As Long
147
153
Next
148
154
End If
149
155
If lPaperSize = 0 Then
156
+ If LenB(sText) <> 0 Then
157
+ sText = ". Not from " & Mid$(sText, 3 )
158
+ End If
150
159
If Not m_oOpt.Item("-q" ) Then
151
- If LenB(sText) <> 0 Then
152
- sText = ". Not from " & Mid$(sText, 3 )
153
- End If
154
160
ConsoleError "Warning: '%1' paper ignored" & sText & vbCrLf, m_oOpt.Item("-paper" )
155
161
End If
156
162
End If
@@ -170,7 +176,7 @@ Private Function Process(vArgs As Variant) As Long
170
176
lOrientation:=lOrientation, _
171
177
vMargins:=vMargins, _
172
178
sError:=sError) Then
173
- ConsoleError sError & vbCrLf & vbCrLf
179
+ ConsoleError sError & vbCrLf
174
180
Process = 2
175
181
GoTo QH
176
182
End If
@@ -182,10 +188,14 @@ Private Function Process(vArgs As Variant) As Long
182
188
Next
183
189
If FileExists(m_oOpt.Item("-o" )) Then
184
190
If Not m_oOpt.Item("-q" ) Then
185
- ConsoleError m_oOpt.Item( "-o" ) & " output successfully!" & vbCrLf & vbCrLf
191
+ ConsoleError "File '%1' output successfully!" & vbCrLf, m_oOpt.Item( "-o" )
186
192
End If
187
193
End If
188
194
QH:
195
+ Exit Function
196
+ EH:
197
+ ConsoleError "Critical error: " & Err.Description & " (0x" & Hex(Err.Number) & ") [Process]" & vbCrLf
198
+ Resume QH
189
199
End Function
190
200
191
201
Private Function SplitArgs (sText As String ) As Variant
@@ -346,7 +356,7 @@ Private Function EnumFiles( _
346
356
Do While LenB(sFile) <> 0
347
357
If sFile <> "." And sFile <> ".." Then
348
358
sFile = PathCombine(sFolder, sFile)
349
- If (GetAttr (sFile) And eAttrib) = eAttrib Then
359
+ If (GetFileAttributes (sFile) And eAttrib + vbVolume ) = eAttrib Then
350
360
RetVal.Add sFile
351
361
End If
352
362
End If
0 commit comments