forked from tannerhelland/VBIDEUtils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Indent.cls
697 lines (597 loc) · 22.6 KB
/
Indent.cls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "class_Indenter"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
' #VBIDEUtils#************************************************************
' * Programmer Name : removed
' * Web Site : http://www.ppreview.net
' * E-Mail : removed
' * Date : 25/11/97
' * Time : 11:17
' * Module Name : class_Indenter
' * Module Filename : Indent.cls
' **********************************************************************
' * Comments : Indent code in an efficient way
' *
' *
' **********************************************************************
Option Explicit
Public nProgDone As Long
Public nProgTotal As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (dest As Any, Source As Any, ByVal bytes As Long)
Private Declare Sub ZeroMemory Lib "kernel32" Alias "RtlZeroMemory" (dest As Any, ByVal bytes As Long)
Private Const STARTBLOCK = 0
Private Const UNALTERED = 1
Private Const MIDBLOCK = 2
Private Const ENDBLOCK = 3
Private Const NOINDENTBLOCK = 4
Private Const CASEBLOCK = 5
Private Const ENDCASEBLOCK = 6
Private Const NOALIGNCOMMENTLOCK = 7
Private Const UNDERSCORECHAR = 8
Private Const LABELLINE = 9
Private Const BLANKLINE = 10
Private Const VARIABLELINE = 11
Private Type LINEINFOS
sTextLine As String ' not used
nNumTabs As Integer
End Type
Private isSeparator(0 To 255) As Boolean
Private sAllLines() As String
Private byteArrayString() As Byte
Private nIndentSpaces As Integer
Private bIndentVariable As Boolean
Private bIndentCase As Boolean
Private bUseTabs As Boolean
Private bIndentProc As Boolean
Private bIndentCmt As Boolean
Private sCharIndent As String * 1
Private sInProc As String
Private sInCode As String
Private sMidCode As String
Private sOutProc As String
Private sOutCode As String
Private sBuffer() As LINEINFOS
Private gbUnderscore As Boolean
Private gsFirstWord As String
Private gsSecondWord As String
Private Sub Class_Initialize()
' #VBIDEUtils#************************************************************
' * Programmer Name : removed
' * Web Site : http://www.ppreview.net
' * E-Mail : removed
' * Date : 25/11/97
' * Time : 10:21
' * Module Name : class_Indenter
' * Module Filename : Indent.cls
' * Procedure Name : Class_Initialize
' * Parameters :
' **********************************************************************
' * Comments : Build a table of separators
' *
' *
' **********************************************************************
Const sSeparators = vbTab & " ,.:;!?""()=-><+&" & vbCrLf
Dim nI As Integer
For nI = 1 To Len(sSeparators)
isSeparator(Asc(Mid$(sSeparators, nI, 1))) = True
Next
' *** Get the desired options
bUseTabs = (GetSetting(gsREG_APP, "Indent", "UseTabs", "N") = "Y")
bIndentProc = (GetSetting(gsREG_APP, "Indent", "IndentProc", "Y") = "Y")
bIndentCmt = (GetSetting(gsREG_APP, "Indent", "IndentCmt", "Y") = "Y")
bIndentCase = (GetSetting(gsREG_APP, "Indent", "IndentCase", "Y") = "Y")
nIndentSpaces = Val(GetSetting(gsREG_APP, "Indent", "IndentSpaces", "3"))
bIndentVariable = (GetSetting(gsREG_APP, "Indent", "IndentVariable", "Y") = "Y")
If bUseTabs Then
sCharIndent = vbTab
Else
sCharIndent = Chr$(32)
End If
If bIndentCase Then
sInProc = sInProc & "Select Case*"
sOutCode = sOutCode & "End Select*"
End If
End Sub
Public Function IndentVBCode(sVBCode As String, sAllLines() As String) As String
' #VBIDEUtils#************************************************************
' * Programmer Name : removed
' * Web Site : http://www.ppreview.net
' * E-Mail : removed
' * Date : 25/11/97
' * Time : 10:21
' * Module Name : class_Indenter
' * Module Filename : Indent.cls
' * Procedure Name : IndentVBCode
' * Parameters :
' * sVBCode As String
' * sAllLines() As String
' **********************************************************************
' * Comments : Indent the VB Code passed as parameter
' *
' *
' **********************************************************************
Dim nI As Long
Dim nJ As Long
Dim nNumberLines As Long
Dim nTab As Integer
Dim sTmp As String
Dim nPos As Integer
Dim nIndent As Byte
Dim sTWA() As String
Call Main_Module.Split(sVBCode, sAllLines, vbCrLf)
nNumberLines = UBound(sAllLines)
ReDim sBuffer(0 To nNumberLines)
' *** Determine number of tabs
frmProgress.Maximum = nProgTotal * 2
For nI = 0 To nNumberLines
If nI Mod 50 = 0 Then frmProgress.Progress = nI
sAllLines(nI) = Replace(sAllLines(nI), Chr$(9), "")
Select Case BlockType(sAllLines(nI))
Case LABELLINE:
sBuffer(nI).nNumTabs = 0
Case STARTBLOCK:
For nJ = nI + 1 To nNumberLines
sBuffer(nJ).nNumTabs = sBuffer(nJ).nNumTabs + 1
Next
Case NOINDENTBLOCK:
sBuffer(nI).nNumTabs = 0
Case MIDBLOCK:
nTab = sBuffer(nI).nNumTabs
For nJ = nI + 1 To nNumberLines
sBuffer(nJ).nNumTabs = nTab
Next
sBuffer(nI).nNumTabs = nTab - 1
Case CASEBLOCK:
sBuffer(nI).nNumTabs = sBuffer(nI).nNumTabs
For nJ = nI + 1 To nNumberLines
sBuffer(nJ).nNumTabs = sBuffer(nJ).nNumTabs + 1
Next
Case ENDCASEBLOCK:
sBuffer(nI).nNumTabs = sBuffer(nI).nNumTabs - 2
nTab = sBuffer(nI).nNumTabs
For nJ = nI + 1 To nNumberLines
sBuffer(nJ).nNumTabs = nTab
Next
Case ENDBLOCK:
sBuffer(nI).nNumTabs = sBuffer(nI).nNumTabs - 1
nTab = sBuffer(nI).nNumTabs
For nJ = nI + 1 To nNumberLines
sBuffer(nJ).nNumTabs = nTab
Next
Case NOALIGNCOMMENTLOCK:
sBuffer(nI).nNumTabs = sBuffer(nI).nNumTabs - 1
Case UNDERSCORECHAR:
If nI + 1 <= nNumberLines Then sBuffer(nI + 1).nNumTabs = sBuffer(nI + 1).nNumTabs + 1
Case VARIABLELINE:
If bIndentVariable Then
On Error Resume Next
nPos = InStr(LCase$(sAllLines(nI)), " as ")
sTmp = Trim$(left$(sAllLines(nI), nPos))
If left$(LCase$(sTmp), 3) = "dim" Then
If sBuffer(nI).nNumTabs = 0 Then
nIndent = 24
Else
nIndent = 21
End If
ElseIf left$(LCase$(sTmp), 6) = "global" Then
nIndent = 24
ElseIf left$(LCase$(sTmp), 6) = "public" Then
nIndent = 24
ElseIf left$(LCase$(sTmp), 7) = "private" Then
nIndent = 24
End If
If Len(sTmp) < nIndent Then
sAllLines(nI) = PadR(sTmp, CInt(nIndent)) & Mid$(sAllLines(nI), nPos + 1)
Else
sAllLines(nI) = sTmp & " " & Mid$(sAllLines(nI), nPos + 1)
End If
On Error GoTo ERROR_IndentVBCode
End If
Case UNALTERED:
If bIndentVariable Then
On Error Resume Next
If right$(Trim$(sAllLines(nI)), 1) <> "_" Then
nPos = InStr(LCase$(sAllLines(nI)), " as ")
If nPos > 0 Then
sTmp = Trim$(sAllLines(nI))
sTmp = Replace(sTmp, " ", " ")
sTmp = Replace(sTmp, " ", " ")
sTmp = Replace(sTmp, " ", " ")
sTmp = Replace(sTmp, " ", " ")
sTmp = Replace(sTmp, " ", " ")
sTmp = Replace(sTmp, " ", " ")
sTmp = Replace(sTmp, " ", " ")
sTmp = Replace(sTmp, " ", " ")
sTmp = Replace(sTmp, " ", " ")
sTmp = Replace(sTmp, " ", " ")
sTmp = Replace(sTmp, " ", " ")
sTmp = Replace(sTmp, ",", " ")
Call Main_Module.Split(sTmp, sTWA, " ")
If LCase$(sTWA(2)) = "as" Then
sTmp = Trim$(left$(sAllLines(nI), nPos))
nIndent = 21
If Len(sTmp) < nIndent Then
sAllLines(nI) = PadR(sTmp, CInt(nIndent)) & Mid$(sAllLines(nI), nPos + 1)
Else
sAllLines(nI) = sTmp & " " & Mid$(sAllLines(nI), nPos + 1)
End If
On Error GoTo ERROR_IndentVBCode
End If
End If
End If
End If
End Select
Next
If bUseTabs Then nIndentSpaces = 1
On Error GoTo ERROR_IndentVBCode
' *** Add tabs in front of each line
For nI = 1 To nNumberLines
If sBuffer(nI).nNumTabs < 0 Then sBuffer(nI).nNumTabs = 0
sAllLines(nI) = Trim$(sAllLines(nI))
If Len(sAllLines(nI)) <> 0 Then
' *** Remove all tabs
Do While Asc(left$(sAllLines(nI), 1)) = 9
sAllLines(nI) = right$(sAllLines(nI), Len(sAllLines(nI)) - 1)
Loop
sTmp = LCase$(sAllLines(nI))
If ((sTmp = "end sub") Or (sTmp = "end function") Or (sTmp = "end property")) And (nI < nNumberLines - 1) Then
' *** Verify if the next line is empty or not
If Trim$(sAllLines(nI + 1)) <> "" Then sAllLines(nI) = sAllLines(nI) & vbCrLf
End If
sAllLines(nI) = String$(nIndentSpaces * sBuffer(nI).nNumTabs, sCharIndent) & sAllLines(nI) & vbCrLf
Else
sAllLines(nI) = Trim$(sAllLines(nI)) & vbCrLf
End If
Next
ERROR_IndentVBCode:
sTmp = Join(sAllLines, vbCrLf)
IndentVBCode = Replace(sTmp, vbCrLf & vbCrLf & vbCrLf, vbCrLf & vbCrLf)
frmProgress.Progress = frmProgress.Maximum
Exit Function
End Function
Private Function BlockType(ByVal sLine As String) As Byte
' #VBIDEUtils#************************************************************
' * Programmer Name : removed
' * Web Site : http://www.ppreview.net
' * E-Mail : removed
' * Date : 25/11/97
' * Time : 10:22
' * Module Name : class_Indenter
' * Module Filename : Indent.cls
' * Procedure Name : BlockType
' * Parameters :
' * ByVal sLine As String
' **********************************************************************
' * Comments : See the needed indent
' *
' *
' **********************************************************************
Dim sFirstWord As String
Dim sSecondWord As String
Dim sLastWord As String
Dim bUnderscore As Boolean
Dim nPos As Long
Dim nPos2 As Long
Static bSelectCase As Boolean
Static nCase As Integer
Static nPrevBlock As Integer
' *** Get the needed words
Call GetWords(sLine, sFirstWord, sSecondWord, sLastWord)
If sLastWord = "_" Then
' *** Middle Code
If (sFirstWord = "else") Or (sFirstWord = "#else") Or (sFirstWord = "elseif") Then
BlockType = MIDBLOCK
nPrevBlock = BlockType
gbUnderscore = True
Exit Function
End If
If gbUnderscore = False Then
If Len(gsFirstWord) = 0 Then gsFirstWord = sFirstWord
If Len(gsSecondWord) = 0 Then gsSecondWord = sSecondWord
gbUnderscore = True
BlockType = UNDERSCORECHAR
Else
'If gsFirstWord = "if" Then
BlockType = UNDERSCORECHAR
'Else
' BlockType = UNALTERED
'End If
End If
nPrevBlock = BlockType
Exit Function
End If
If gbUnderscore Then
If (sSecondWord <> "") And (gsFirstWord = "if") And (sLastWord = "") And (sFirstWord = "then") Then
sFirstWord = gsFirstWord
sLastWord = sSecondWord
sSecondWord = gsSecondWord
Else
If Len(sLastWord) = 0 Then sLastWord = sFirstWord
sFirstWord = gsFirstWord
sSecondWord = gsSecondWord
End If
gbUnderscore = False
gsFirstWord = ""
gsSecondWord = ""
End If
BlockType = UNALTERED
' *** Special treatment for comments
If ((left$(Trim$(sLine), 1) = "'") Or _
(LCase$(left$(Trim$(sLine), 3)) = "rem")) And bIndentCmt = False Then
BlockType = NOALIGNCOMMENTLOCK
nPrevBlock = BlockType
Exit Function
End If
' *** Label line
If (right$(sLine, 1) = ":") And (left$(Trim$(sLine), 1) <> "'") And (sFirstWord <> "case") And (sFirstWord <> "if") Then
nPos = InStrRev(sLine, "'") ' *** Search Comment
nPos2 = InStrRev(sLine, """") ' *** Search String
If (nPos = 0) Or (nPos2 > nPos) Then
BlockType = LABELLINE
nPrevBlock = BlockType
Exit Function
End If
End If
' *** Special treatment for Select/Case
If sFirstWord = "case" Then
If bIndentCase Then
If bSelectCase = True Then
bSelectCase = False
BlockType = CASEBLOCK
Else
BlockType = MIDBLOCK
End If
nCase = nCase + 1
Else
BlockType = MIDBLOCK
End If
nPrevBlock = BlockType
Exit Function
End If
' *** Some unaltered code
If sFirstWord = "if" And sLastWord <> "then" Then Exit Function
' *** Middle Code
If (sFirstWord = "else") Or _
(sFirstWord = "#else") Or _
(sFirstWord = "elseif") Then
BlockType = MIDBLOCK
nPrevBlock = BlockType
Exit Function
End If
' *** Indent Code
If (sFirstWord = "if") Or _
(sFirstWord = "#if") Or _
(sFirstWord = "type") Or _
(sFirstWord = "enum") Or _
(sFirstWord = "with") Or _
(sFirstWord = "for") Or _
(sFirstWord = "do") Or _
(sFirstWord = "while") Or _
((sFirstWord = "select") And (sSecondWord = "case")) Or _
((sFirstWord = "public") And (sSecondWord = "type")) Or _
((sFirstWord = "private") And (sSecondWord = "type")) Or _
((sFirstWord = "public") And (sSecondWord = "enum")) Or _
((sFirstWord = "private") And (sSecondWord = "enum")) Then
If ((sFirstWord = "select") And (sSecondWord = "case")) Then bSelectCase = True
If ((sFirstWord = "type") And (sSecondWord = "as")) Then
BlockType = UNALTERED
Exit Function
End If
If (nPrevBlock <> STARTBLOCK) Or (sFirstWord <> "enum") Then
BlockType = STARTBLOCK
nPrevBlock = BlockType
Exit Function
End If
End If
' *** Outdent Code
If (sFirstWord = "next") Or _
(sFirstWord = "loop") Or _
(sFirstWord = "wend") Or _
((sFirstWord = "end") And (sSecondWord = "if")) Or _
((sFirstWord = "#end") And (sSecondWord = "if")) Or _
((sFirstWord = "end") And (sSecondWord = "select")) Or _
((sFirstWord = "end") And (sSecondWord = "type")) Or _
((sFirstWord = "end") And (sSecondWord = "enum")) Or _
((sFirstWord = "end") And (sSecondWord = "with")) Then
If ((sFirstWord = "end") And (sSecondWord = "select")) And (nCase > 0) Then
nCase = nCase - 1
BlockType = ENDCASEBLOCK
nPrevBlock = BlockType
Exit Function
End If
BlockType = ENDBLOCK
nPrevBlock = BlockType
Exit Function
End If
If bIndentProc = False Then Exit Function
' *** Indent procedure
If (sFirstWord = "sub") Or _
(sFirstWord = "function") Or _
(sFirstWord = "property") Or _
(sFirstWord = "for") Or _
(sFirstWord = "do") Or _
(sFirstWord = "while") Or _
((sFirstWord = "static") And (sSecondWord = "sub")) Or _
((sFirstWord = "static") And (sSecondWord = "function")) Or _
((sFirstWord = "private") And (sSecondWord = "sub")) Or _
((sFirstWord = "private") And (sSecondWord = "function")) Or _
((sFirstWord = "private") And (sSecondWord = "property")) Or _
((sFirstWord = "private") And (sSecondWord = "static")) Or _
((sFirstWord = "friend") And (sSecondWord = "sub")) Or _
((sFirstWord = "friend") And (sSecondWord = "function")) Or _
((sFirstWord = "friend") And (sSecondWord = "property")) Or _
((sFirstWord = "friend") And (sSecondWord = "static")) Or _
((sFirstWord = "public") And (sSecondWord = "sub")) Or _
((sFirstWord = "public") And (sSecondWord = "function")) Or _
((sFirstWord = "public") And (sSecondWord = "property")) Or _
((sFirstWord = "public") And (sSecondWord = "static")) Then
' *** Procedure in 1 line
If ((sFirstWord = "sub") And (sLastWord = "sub")) Or _
((sFirstWord = "function") And (sLastWord = "function")) Or _
((sFirstWord = "property") And (sLastWord = "property")) Or _
((sSecondWord = "sub") And (sLastWord = "sub")) Or _
((sSecondWord = "function") And (sLastWord = "function")) Or _
((sSecondWord = "property") And (sLastWord = "property")) Then
nPrevBlock = BlockType
Exit Function
End If
' *** Indent procedure
BlockType = STARTBLOCK
nPrevBlock = BlockType
Exit Function
End If
' *** Outdent procedure
If ((sFirstWord = "end") And (sSecondWord = "sub")) Or _
((sFirstWord = "end") And (sSecondWord = "function")) Or _
((sFirstWord = "end") And (sSecondWord = "property")) Then
BlockType = ENDBLOCK
nPrevBlock = BlockType
Exit Function
End If
If (sFirstWord = "dim") Or _
(sFirstWord = "public") Or _
(sFirstWord = "private") Or _
(sFirstWord = "global") Then
nPos = InStr(LCase$(sLine), " as ")
If nPos > 0 Then
BlockType = VARIABLELINE
End If
End If
nPrevBlock = BlockType
End Function
Private Sub GetWords(ByVal sLine As String, sFirstWord As String, sSecondWord As String, sLastWord As String)
' #VBIDEUtils#************************************************************
' * Programmer Name : removed
' * Web Site : http://www.ppreview.net
' * E-Mail : removed
' * Date : 24/11/98
' * Time : 17:09
' * Module Name : class_Indenter
' * Module Filename : Indent.cls
' * Procedure Name : GetWords
' * Parameters :
' * ByVal sLine As String
' * sFirstWord As String
' * sSecondWord As String
' * sLastWord As String
' **********************************************************************
' * Comments : Get all the needed words
' *
' *
' **********************************************************************
Dim nI As Long
Dim nJ As Long
sFirstWord = ""
sSecondWord = ""
sLastWord = ""
sLine = Trim$(LCase$(sLine)) ' this line is not optim.
' *** Remove things in strings
nI = InStr(1, sLine, """")
Do Until nI = 0
nJ = InStr(nI + 1, sLine, """")
If nJ = 0 Then nJ = nI + 1
sLine = left$(sLine, nI) & Mid$(sLine, nJ)
nI = InStr(nI + 2, sLine, """")
Loop
' *** Remove trailing comments from the line
nI = InStr(1, sLine, "'")
If nI > 0 Then sLine = left$(sLine, nI - 1)
nI = InStr(sLine, Chr$(39)) - 1
If nI > 0 Then sLine = left$(sLine, nI)
If left$(sLine, 1) = Chr$(39) Then Exit Sub
If Len(sLine) = 0 Then Exit Sub
Dim nSize As Integer
sLine = Trim$(sLine)
nSize = Len(sLine)
If nSize = 0 Then Exit Sub
ReDim byteArrayString(1 To nSize)
' *** Copy string to byte array
Call CopyMemory(byteArrayString(1), ByVal sLine, nSize)
Dim nStartWord As Integer
Dim nSavPosition As Integer
' *** Get FirstWord
nStartWord = 1
For nI = 1 To nSize
If isSeparator(byteArrayString(nI)) Then
sFirstWord = Space$(nI - nStartWord)
CopyMemory ByVal sFirstWord, byteArrayString(nStartWord), nI - nStartWord
nSavPosition = nI + 1
Exit For
End If
Next
If nSavPosition = 0 Then
sFirstWord = Space$(nI - nStartWord)
CopyMemory ByVal sFirstWord, byteArrayString(nStartWord), nI - nStartWord
Exit Sub
End If
' *** Remove all blanks
If nSavPosition < nSize Then
Do While (byteArrayString(nSavPosition) = 32) And (nSavPosition < nSize)
nSavPosition = nSavPosition + 1
Loop
End If
' *** Get SecondWord
nStartWord = nSavPosition
For nI = nSavPosition To nSize
If isSeparator(byteArrayString(nI)) Then
sSecondWord = Space$(nI - nStartWord)
CopyMemory ByVal sSecondWord, byteArrayString(nStartWord), nI - nStartWord
nSavPosition = nI + 1
Exit For
End If
Next
If nSavPosition = nStartWord Then
sSecondWord = Space$(nI - nStartWord)
If (nI - nStartWord) > 0 Then
CopyMemory ByVal sSecondWord, byteArrayString(nStartWord), nI - nStartWord
End If
sLastWord = sSecondWord
Exit Sub
End If
' *** Get LastWord
For nI = nSize To nSavPosition Step -1
If isSeparator(byteArrayString(nI)) Then
sLastWord = Space$(nSize - nI)
If (nSize - nI) > 0 Then
CopyMemory ByVal sLastWord, byteArrayString(nI + 1), nSize - nI
End If
Exit For
End If
Next
If (nI = nSavPosition - 1) Then
If isSeparator(byteArrayString(nI)) Then
sLastWord = Space$(nSize - nI)
If (nSize - nI) > 0 Then
CopyMemory ByVal sLastWord, byteArrayString(nI + 1), nSize - nI
End If
End If
End If
End Sub
Private Sub Class_Terminate()
' #VBIDEUtils#************************************************************
' * Programmer Name : removed
' * Web Site : http://www.ppreview.net
' * E-Mail : removed
' * Date : 25/11/97
' * Time : 10:26
' * Module Name : class_Indenter
' * Module Filename : Indent.cls
' * Procedure Name : Class_Terminate
' * Parameters :
' **********************************************************************
' * Comments : Terminate all and clear all memory
' *
' *
' **********************************************************************
Erase sAllLines
End Sub