-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmytoolkit.vbs
executable file
·2282 lines (2238 loc) · 53.9 KB
/
mytoolkit.vbs
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
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Option Explicit
''==================================================
''
'' 標準入出力クラス
''
Class MyStdio
Dim objStdin
Dim objStdout
Dim objStderr
Dim bReadSuccess
Sub Class_initialize()
Set objStdin = WScript.StdIn
Set objStdout = WScript.StdOut
Set objStderr = WScript.StdErr
bReadSuccess = false
End Sub
'
' 機 能:標準入力より1行取得
' 戻り値:レコード
' 例 :strRec = MyStdio.readLine
'
Function readLine()
If objStdin.AtEndOfStream Then
readLine = ""
bReadSuccess = false
Else
On Error Resume Next
readLine = objStdin.ReadLine()
If Err.Number = 0 Then
bReadSuccess = true
Else
bReadSuccess = false
End If
On Error Goto 0
End If
End Function
'
' 機 能:標準入力より指定文字数分取得
' 引 数:count 取得する文字数
' 戻り値:文字列
' 例 :strRec = MyStdio.read(128)
'
Function read(count)
If objStdin.AtEndOfStream Then
read = ""
bReadSuccess = false
Else
On Error Resume Next
read = objStdin.Read(count)
If Err.Number = 0 Then
bReadSuccess = true
Else
bReadSuccess = false
End If
On Error Goto 0
End If
End Function
'
' 機 能:標準入力読み取り成功チェック
' 戻り値:true or false
' 例 :While MyStdio.isRaedSuccess
'
Function isReadSuccess()
isReadSuccess = bReadSuccess
End Function
'
' 機 能:標準入力読み取り失敗チェック
' 戻り値:true or false
' 例 :While Not MyStdio.isRaedFailure
'
Function isReadFailure()
isReadFailure = Not isReadSuccess
End Function
'
' 機 能:標準出力に1行出力
' 引 数:str レコード
' 例 :MyStdio.writeLine strRec
'
Function writeLine(str)
objStdout.WriteLine str
End Function
'
' 機 能:標準出力に指定文字列を出力
' 引 数:str 文字列
' 例 :MyStdio.write strString
'
Function write(str)
objStdout.Write str
End Function
'
' 機 能:標準エラー出力に1行出力
' 引 数:str レコード
' 例 :MyStdio.writeErrorLine strRec
'
Function writeErrorLine(str)
objStderr.WriteLine str
End Function
'
' 機 能:標準エラー出力に指定文字列を出力
' 引 数:str 文字列
' 例 :MyStdio.writeError strString
'
Function writeError(str)
objStderr.Write str
End Function
'
' 機 能:標準入力の終端を取得
' 戻 値:True(終端時) or False(非終端時)
' 例 :While Not isEof
'
Function isEof()
isEof = objStdin.AtEndOfStream
End Function
End Class
''==================================================
''
'' 文字列クラス
''
Class MyString
Dim value
Dim booleanHighValue
Dim booleanLowValue
Dim objRegex
Sub Class_initialize()
value = ""
booleanHighValue = false
booleanLowValue = false
Set objRegex = CreateObject("VBScript.RegExp")
End Sub
'
' 機 能:文字列を設定
' 引 数:str 文字列
' 例 :MyString.setValue strString
'
Function setValue(str)
value = CStr(str)
booleanHighValue = false
booleanLowValue = false
End Function
'
' 機 能:文字列を取得
' 戻 値:文字列
' 例 :strString = MyString.getValue
'
Function getValue()
getValue = CStr(value)
End Function
'
' 機 能:正規表現との一致を取得
' 引 数:regex 正規表現
' 戻 値:True(一致時) or False(不一致時)
' 例 :If MyString.isMatch("^A.*Z$")
'
Function isMatch(regex)
objRegex.Pattern = regex
isMatch = objRegex.Test(value)
End Function
'
' 機 能:正規表現に一致した部分を別の文字列に置き換えるた文字列の取得
' 引 数:regex 正規表現
' str 置換後の文字列
' 戻 値:文字列
' 例 :strString = MyString.getReplace("^A.*Z$", "A to Z")
'
Function getReplace(regex, str)
objRegex.Global = True
objRegex.Pattern = regex
getReplace = objRegex.Replace(value, str)
End Function
'
' 機 能:指定した区切り文字で区切って配列で取得
' 引 数:del 区切り文字
' 戻 値:文字列配列
' 例 :strArray = MyString.getSplit(",")
'
Function getSplit(del)
getSplit = split(value, del)
End Function
'
' 機 能:文字列長を取得
' 戻 値:文字列長
' 例 :intLength = MyString.getLength
'
Function getLength()
getLength = len(value)
End Function
'
' 機 能:部分文字列を取得
' 引 数:start 開始位置(1オリジン)
' length 文字列長
' 戻 値:文字列
' 例 :strString = MyString.Substr(1,5)
'
Function getSubstr(start, length)
getSubstr = Mid(value, start, length)
End Function
'
' 機 能:文字列を16進数コードに変換
' 戻 値:文字列
' 例 :strHexString = MyString.getHexString
'
Function getHexString()
Dim strChar
Dim strHex
Dim intLen
Dim intCnt
strHex = ""
intLen = Len(value)
For intCnt = 1 To intLen
strChar = Mid(value, intCnt, 1)
strHex = strHex & Hex(Asc(strChar))
Next
getHexString = strHex
End Function
'
' 機 能:HIGH-VALUEをセットする
' 例 :MyString.setHighValue
'
Function setHighValue()
booleanHighValue = true
value = ""
End Function
'
' 機 能:HIGH-VALUEか確認する
' 戻 値:True or False
' 例 :MyString.isHighValue
'
Function isHighValue()
isHighValue = booleanHighValue
End Function
'
' 機 能:LOW-VALUEをセットする
' 例 :MyString.setLowValue
'
Function setLowValue()
booleanLowValue = true
value = ""
End Function
'
' 機 能:LOW-VALUEか確認する
' 戻 値:True or False
' 例 :MyString.isLowValue
'
Function isLowValue()
isLowValue = booleanLowValue
End Function
'
' 機 能:等しいか確認する
' 戻 値:True or False
' 例 :MyString.isEqual(objString)
'
Function isEqual(objString)
Dim stat
If isHighValue Then
If objString.isHighValue Then
stat = true
Else
stat = false
End If
ElseIf isLowValue Then
If objString.isLowValue Then
stat = true
Else
stat = false
End If
Else
If objString.isHighValue or objString.isLowValue Then
stat = false
Else
If CStr(value) = CStr(objString.getValue) Then
stat = true
Else
stat = false
End If
End If
End If
isEqual = stat
End Function
'
' 機 能:大きいか確認する
' 戻 値:True or False
' 例 :MyString.isGreater(objString)
'
Function isGreater(objString)
Dim stat
If isHighValue Then
If objString.isHighValue Then
stat = false
Else
stat = true
End If
ElseIf isLowValue Then
stat = false
Else
If objString.isHighValue Then
stat = false
ElseIf objString.isLowValue Then
stat = True
Else
If CStr(value) > CStr(objString.getValue) Then
stat = true
Else
stat = false
End If
End If
End If
isGreater = stat
End Function
'
' 機 能:小さいか確認する
' 戻 値:True or False
' 例 :MyString.isLess(objString)
'
Function isLess(objString)
Dim stat
If isEqual(objString) Then
stat = false
ElseIf isGreater(objString) Then
stat = false
Else
stat = true
End If
isLess = stat
End Function
End Class
''==================================================
''
'' 引数クラス
''
Class MyArg
Dim objArg
Sub Class_initialize()
Set objArg = WScript.Arguments
End Sub
'
' 機 能:引数の個数を取得
' 戻 値:引数の個数
' 例 :intCount= MyArg.getCount
'
Function getCount()
getCount = objArg.Count
End Function
'
' 機 能:指定した引数の取得
' 引 数:インデックス(0オリジン)
' 戻 値:文字列
' 例 :strArg= MyArg.getValue(0)
'
Function getValue(idx)
getValue = objArg(idx)
End Function
End Class
''==================================================
''
'' FileSystemObjectクラス(Shift_JIS)
''
Class MyFso
Dim objFso
Dim objFile
Dim strFilename
Dim strMode
Dim bReadSuccess
Sub Class_initialize()
Set objFile = Nothing
Set objFso = Nothing
strFilename = ""
strMode = ""
bReadSuccess = false
End Sub
'
' 機 能:FSOを開く
' 引 数:filename ファイル名
' mode "r"(読み込み) or "w"(書き込み)
' 例 :MyFso.open "INPUT.TXT", "r"
'
Function open(filename, mode)
Set objFso = CreateObject("Scripting.FileSystemObject")
If mode = "r" Then
Set objFile = objFso.OpenTextFile(filename, 1, False)
Elseif mode = "w" Then
Set objFile = objFso.OpenTextFile(filename, 2, True)
End If
strFilename = filename
strMode = mode
End Function
'
' 機 能:FSOを入力モードで開く
' 引 数:filename ファイル名
' 例 :MyFso.openInput "INPUT.TXT"
'
Function openInput(filename)
open filename, "r"
End Function
'
' 機 能:FSOを出力モードで開く
' 引 数:filename ファイル名
' 例 :MyFso.openOutput "OUTPUT.TXT"
'
Function openOutput(filename)
open filename, "w"
End Function
'
' 機 能:1行取得
' 戻り値:レコード
' 例 :strRec = MyFso.readLine
'
Function readLine()
If objFile.AtEndOfStream Then
readLine = ""
bReadSuccess = false
Else
On Error Resume Next
readLine = objFile.ReadLine
If Err.Number = 0 Then
bReadSuccess = true
Else
bReadSuccess = false
End If
On Error Goto 0
End If
End Function
'
' 機 能:指定文字数分取得
' 引 数:count 取得する文字数
' 戻り値:文字列
' 例 :strString = MyFso.read(128)
'
Function read(count)
If objFile.AtEndOfStream Then
read = ""
bReadSuccess = false
Else
On Error Resume Next
read = objFile.Read(count)
If Err.Number = 0 Then
bReadSuccess = true
Else
bReadSuccess = false
End If
On Error Goto 0
End If
End Function
'
' 機 能:読み取り成功チェック
' 戻り値:true or false
' 例 :While MyFso.isReadSuccess
'
Function isReadSuccess()
isReadSuccess = bReadSuccess
End Function
'
' 機 能:読み取り失敗チェック
' 戻り値:true or false
' 例 :While Not MyFso.isReadFailure
'
Function isReadFailure()
isReadFailure = Not isReadSuccess
End Function
'
' 機 能:1行出力
' 引 数:str レコード
' 例 :MyFso.writeLine strRec
'
Function writeLine(str)
objFile.WriteLine str
End Function
'
' 機 能:指定文字列を出力
' 引 数:str 文字列
' 例 :MyFso.write strString
'
Function write(str)
objFile.Write str
End Function
'
' 機 能:終端を取得
' 戻 値:True(終端時) or False(非終端時)
' 例 :While Not MyFso.isEof
'
Function isEof()
isEof = objFile.AtEndOfStream
End Function
'
' 機 能:FSOを閉じる
' 例 :MyFso.close
'
Function close()
objFile.close
Set objFile = Nothing
Set objFso = Nothing
strFilename = ""
strMode = ""
End Function
End Class
''==================================================
''
'' ActiveX Data Objectクラス(文字コード指定可能)
''
Class MyAdo
Dim objStream
Dim strFilename
Dim strMode
Dim strCharset
Dim booleanBomForUtf8
Dim bReadSuccess
Sub Class_initialize()
Set objStream = Nothing
strFilename = ""
strMode = ""
strCharset = ""
booleanBomForUtf8 = False
bReadSuccess = false
End Sub
'
' 機 能:ADOを開く
' 引 数:filename ファイル名
' mode "r"(読み込み) or "w"(書き込み)
' charset "UTF-8" or "Shift_JIS" or "ASCII" etc
' bom True(UTF-8の時BOM付きで出力) or
' False(UTF-8の時BOM無しで出力)
' 例 :MyAdo.open "INPUT.TXT", "r", "UTF-8", False
'
Function open(filename, mode, charset, bom)
Set objStream = CreateObject("ADODB.Stream")
objStream.charset = charset
objStream.type = 2 ' text
objStream.open
If mode = "r" Then
objStream.LoadFromFile filename
End If
strFilename = filename
strMode = mode
strCharset = charset
booleanBomForUtf8 = bom
End Function
'
' 機 能:ADOを入力モードで開く
' 引 数:filename ファイル名
' charset "UTF-8" or "Shift_JIS" or "ASCII" etc
' 例 :MyAdo.openInput "INPUT.TXT", "UTF-8"
'
Function openInput(filename, charset)
open filename, "r", charset, False
End Function
'
' 機 能:ADOを出力モードで開く
' 引 数:filename ファイル名
' charset "UTF-8" or "Shift_JIS" or "ASCII" etc
' 例 :MyAdo.openOutput "OUTPUT.TXT", "UTF-8"
'
Function openOutput(filename, charset)
open filename, "w", charset, False
End Function
'
' 機 能:1行取得
' 戻り値:レコード
' 例 :strRec = MyAdo.readLine
'
Function readLine()
If objStream.EOS Then
readLine = ""
bReadSuccess = false
Else
On Error Resume Next
readLine = objStream.ReadText(-2)
If Err.Number = 0 Then
bReadSuccess = true
Else
bReadSuccess = false
End If
On Error Goto 0
End If
End Function
'
' 機 能:読み取り成功チェック
' 戻り値:true or false
' 例 :While MyAdo.isReadSuccess
'
Function isReadSuccess()
isReadSuccess = bReadSuccess
End Function
'
' 機 能:読み取り失敗チェック
' 戻り値:true or false
' 例 :While Not MyAdo.isReadFailure
'
Function isReadFailure()
isReadFailure = Not isReadSuccess
End Function
'
' 機 能:1行出力
' 引 数:str レコード
' 例 :MyAdo.writeLine strRec
'
Function writeLine(record)
objStream.WriteText record, 1
End Function
'
' 機 能:ADOを閉じる
' 例 :MyAdo.close
'
Function close()
If strMode = "w" Then
If strCharset = "UTF-8" Then
If booleanBomForUtf8 Then
save()
Else
saveWithoutBom()
End If
Else
save()
End If
End If
objStream.close
Set objStream = Nothing
End Function
'
' 機 能:終端を取得
' 戻 値:True(終端時) or False(非終端時)
' 例 :While Not MyAdo.isEof
'
Function isEof()
isEof = objStream.EOS
End Function
'
' 機 能:保存する
' 例 :MyAdo.save
'
Private Function save()
objStream.SaveToFile strFilename, 2
End Function
'
' 機 能:先頭の3bytesを除いて保存する
' 例 :MyAdo.saveWithoutBom
'
Private Function saveWithoutBom()
objStream.Position = 0
objStream.Type = 1
objStream.Position = 3
Dim bin : bin = objStream.Read()
Dim stm : Set stm = CreateObject("ADODB.Stream")
stm.Type = 1
stm.Open()
stm.Write(bin)
stm.SaveToFile strFilename, 2
stm.Close()
End Function
End Class
''==================================================
''
'' CSVクラス
''
Class MyCsv
Dim strValues
Dim strNames
Dim strDel
Dim objStr
Dim objDict
Sub Class_initialize()
strValues = Array()
strNames = ""
strDel = ","
Set objStr = new MyString
Set objDict = CreateObject("Scripting.Dictionary")
End Sub
'
' 機 能:レコードの初期化
' 引 数:count レコードの項目数
' 例 :MyCsv.initRec 16
'
Function initRec(count)
ReDim strValues(count - 1)
End Function
'
' 機 能:レコード(区切り文字含む)を設定
' 引 数:str 文字列(項目名1{区切り文字}項目名2{区切り文字}...)
' 例 :MyCsv.setRec strRec
'
Function setRec(str)
objStr.setValue(str)
strValues = objStr.getSplit(strDel)
End Function
'
' 機 能:レコードを取得
' 戻 値:レコード(区切り文字含む)
' 例 :strRec = MyCsv.getRec
'
Function getRec()
Dim strRec
Dim i
strRec = ""
If UBound(strValues) >= 0 Then
strRec = strValues(0)
For i = 1 to UBound(strValues)
strRec = strRec & strDel & strValues(i)
Next
End If
getRec = strRec
End Function
'
' 機 能:項目名レコードを設定
' 引 数:str 文字列(項目名1{区切り文字}項目名2{区切り文字}...)
' 例 :MyCsv.setNameRec strNameRec
'
Function setNameRec(str)
Dim strArray
Dim i
strArray = Split(str, strDel)
For i = 0 to UBound(strArray)
objDict.Add strArray(i), i
Next
strNames = strDel
End Function
'
' 機 能:項目名レコードを取得
' 戻り値:文字列(項目名1{区切り文字}項目名2{区切り文字}...)
' 例 :strNameRec = MyCsv.getNameRec
'
Function getNameRec()
getNameRec = strNames
End Function
'
' 機 能:区切り文字を設定
' 引 数:del 区切り文字列
' 例 :MyCsv.setDelimiter ","
'
Function setDelimiter(del)
strDel = del
End Function
'
' 機 能:区切り文字を取得
' 戻り値:文字
' 例 :charDel = MyCsv.getDelimiter
'
Function getDelimiter()
getDelimiter = strDel
End Function
'
' 機 能:インデックス指定で項目を取得
' 引 数:i インデックス(0オリジン)
' 戻り値:文字列
' 例 :strString = MyCsv.getValueByIndex(0)
'
Function getValueByIndex(i)
If 0 <= i And i <= UBound(strValues) Then
getValueByIndex = strValues(i)
Else
getValueByIndex = ""
End If
End Function
'
' 機 能:インデックス指定で項目を設定
' 引 数:i インデックス(0オリジン)
' value 文字列
' 戻り値:文字列
' 例 :MyCsv.setValueByIndex 0, "STRING"
'
Function setValueByIndex(i, value)
If 0 <= i And i <= UBound(strValues) Then
strValues(i) = value
End If
End Function
'
' 機 能:最終インデックスを取得
' 戻り値:整数(0オリジン)
' 例 :intIndex = MyCsv.getLastIndex
'
Function getLastIndex()
getLastIndex = UBound(strValues)
End Function
'
' 機 能:項目名に対応したインデックスを取得
' 引 数:name 項目名
' 戻り値:整数(0オリジン)
' 例 :intIndex = MyCsv.getIndexByName("ELEMENT_01")
'
Function getIndexByName(name)
If objDict.Exists(name) Then
getIndexByName = objDict(name)
Else
getIndexByName = -1
End If
End Function
'
' 機 能:項目名指定で項目を取得
' 引 数:name 項目名
' 戻り値:文字列
' 例 :strString = MyCsv.getValueByName("ELEMENT_01")
'
Function getValueByName(name)
getValueByName = getValueByIndex(getIndexByName(name))
End Function
'
' 機 能:項目名指定で項目を設定
' 引 数:name 項目名
' value 文字列
' 戻り値:文字列
' 例 :MyCsv.setValueByName "ELEMENT_01", 123
'
Function setValueByName(name, value)
setValueByIndex getIndexByName(name), value
End Function
End Class
''==================================================
''
'' 標準入出力CSVクラス
''
Class MyStdioCsv
Dim objStdio
Dim objCsv
Sub Class_initialize()
Set objStdio = new MyStdio
Set objCsv = new MyCsv
End Sub
'
' 機 能:レコードの初期化
' 引 数:count レコードの項目数
' 例 :MyStdioCsv.initRec 16
'
Function initRec(count)
objCsv.initRec count
End Function
'
' 機 能:レコード(区切り文字含む)を設定
' 引 数:str 文字列(項目名1{区切り文字}項目名2{区切り文字}...)
' 例 :MyStdioCsv.setRec strRec
'
Function setRec(str)
objCsv.setRec str
End Function
'
' 機 能:レコードを取得
' 戻 値:レコード(区切り文字含む)
' 例 :strRec = MyStdioCsv.getRec
'
Function getRec()
getRec = objCsv.getRec
End Function
'
' 機 能:項目名レコードを設定
' 引 数:str 文字列(項目名1{区切り文字}項目名2{区切り文字}...)
' 例 :MyStdioCsv.setNameRec strNameRec
'
Function setNameRec(str)
objCsv.setNameRec str
End Function
'
' 機 能:項目名レコードを取得
' 戻り値:文字列(項目名1{区切り文字}項目名2{区切り文字}...)
' 例 :strNameRec = MyStdioCsv.getNameRec
'
Function getNameRec()
getNameRec = objCsv.getNameRec
End Function
'
' 機 能:区切り文字を設定
' 引 数:del 区切り文字列
' 例 :MyStdioCsv.setDelimiter ","
'
Function setDelimiter(del)
objCsv.setDelimiter del
End Function
'
' 機 能:区切り文字を取得
' 戻り値:文字
' 例 :charDel = MyStdioCsv.getDelimiter
'
Function getDelimiter()
getDelimiter = objCsv.getDelimiter
End Function
'
' 機 能:インデックス指定で項目を取得
' 引 数:i インデックス(0オリジン)
' 戻り値:文字列
' 例 :strString = MyStdioCsv.getValueByIndex(0)
'
Function getValueByIndex(i)
getValueByIndex = objCsv.getValueByIndex(i)
End Function
'
' 機 能:インデックス指定で項目を設定
' 引 数:i インデックス(0オリジン)
' value 文字列
' 戻り値:文字列
' 例 :MyStdioCsv.setValueByIndex 0, "STRING"
'
Function setValueByIndex(i, value)
objCsv.setValueByIndex i, value
End Function
'
' 機 能:最終インデックスを取得
' 戻り値:整数(0オリジン)
' 例 :intIndex = MyStdioCsv.getLastIndex
'
Function getLastIndex()
getLastIndex = objCsv.getLastIndex
End Function
'
' 機 能:項目名に対応したインデックスを取得
' 引 数:name 項目名
' 戻り値:整数(0オリジン)
' 例 :intIndex = MyStdioCsv.getIndexByName("ELEMENT_01")
'
Function getIndexByName(name)
getIndexByName = objCsv.getIndexByName(name)
End Function
'
' 機 能:項目名指定で項目を取得
' 引 数:name 項目名
' 戻り値:文字列
' 例 :strString = MyStdioCsv.getValueByName("ELEMENT_01")
'
Function getValueByName(name)
getValueByName = objCsv.getValueByName(name)
End Function
'
' 機 能:項目名指定で項目を設定
' 引 数:name 項目名
' value 文字列
' 戻り値:文字列
' 例 :MyStdioCsv.setValueByName "ELEMENT_01", 123
'
Function setValueByName(name, value)
objCsv.setValueByName name, value
End Function
'
' 機 能:標準入力より1行CSVレコード取得を取得し、objCsvへ保存
' 戻り値:True(読めた) or False(読めなかった)
' 例 :MyStdioCsv.readLine
'
Function readLine()
Dim strRec
strRec = objStdio.readLine
If objStdio.isReadSuccess Then
objCsv.setRec strRec
readLine = True
Else
objCsv.setRec ""
readLine = False
End If
End Function
'
' 機 能:objCsvから標準出力に1行CSVレコード出力
' 例 :MyStdioCsv.writeLine
'
Function writeLine()
objStdio.writeLine objCsv.getRec
End Function
'
' 機 能:objCsvから標準エラー出力にCSVレコード出力
' 引 数:str レコード
' 例 :MyStdioCsv.writeErrorLine
'
Function writeErrorLine
objStdio.writeErrorLine objCsv.getRec
End Function
'
' 機 能:標準入力読み取り成功チェック
' 戻り値:true or false
' 例 :While MyStdioCsv.isRaedSuccess
'
Function isReadSuccess()
isReadSuccess = objStdio.isReadSuccess
End Function
'
' 機 能:標準入力読み取り失敗チェック
' 戻り値:true or false
' 例 :While Not MyStdioCsv.isRaedFailure
'
Function isReadFailure()
isReadFailure = objStdio.isReadFailure
End Function
'
' 機 能:標準入力の終端を取得
' 戻 値:True(終端時) or False(非終端時)
' 例 :While Not MyStdioCsv.isEof
'
Function isEof()
isEof = objStdio.isEof
End Function
End Class
''==================================================
''
'' FileSystemObjectCSVクラス(Shift_JIS)
''
Class MyFsoCsv
Dim objFso
Dim objCsv