C#還OK,反正公司有人會。反而比較冷門沒人會。
不要選我當版主
// stdafx.h : include file for standard system include files, // or project specific include files that are used frequently, but // are changed infrequently // #if !defined(AFX_STDAFX_H__3652E740_3773_441A_9233_942284587DB6__INCLUDED_) #define AFX_STDAFX_H__3652E740_3773_441A_9233_942284587DB6__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers #include <stdio.h> #include <stdlib.h> #include <string.h> #include <windows.h> #include <time.h> #include <io.h> #include <sys/stat.h> #define IC 1024//16384 #define A 2048 #define B 1024 #define C 8 #define Max_Size 256 #define Min_Size 32 extern char FileList[Max_Size][Max_Size]; extern unsigned int FileCount; extern float TestResult[IC][B]; extern int My_Max_x; extern int My_Max_y; extern int My_Min_x; extern int My_Min_y; extern int ErrorCoord; extern time_t start_tm,finish_tm; #define Test_policy "Never merge tests with identical test number if test name not matching" #define Outlier_removal "None (keep all data)" #define Statistics_computation "From samples data (if any)- otherwise from summary" #define Binning_computation "From summary data (if any)- otherwise from samples" #define Cp_Cpk_computation "Use standard Sigma formula" #define Mean_drift_formula "Percentage of value drift" #define Parts_processed "All Data / parts (any Bin)" #define Data_from_Site "All sites" #define FOREGROUND_WHITE (FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY) // TODO: reference additional headers your program requires here //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_STDAFX_H__3652E740_3773_441A_9233_942284587DB6__INCLUDED_)
// stdafx.cpp : source file that includes just the standard includes // Analysis.pch will be the pre-compiled header // stdafx.obj will contain the pre-compiled type information #include "stdafx.h" // TODO: reference any additional headers you need in STDAFX.H // and not in this file char FileList[Max_Size][Max_Size]={0}; unsigned int FileCount=0; float TestResult[IC][B]={0}; int My_Max_x=0; int My_Max_y=0; int My_Min_x=0; int My_Min_y=0; time_t start_tm=0; time_t finish_tm=0; int ErrorCoord=0;
Option Explicit Dim TargetFileName As String, SourceFolder As String Dim FileNameArray() As String, Tmp() As String Private Const FileType = ".csv" Sub Main() Dim TempString As String, Temp() As String, Temp1() As String If Trim$(Command) <> "" Then Temp = Split(Command, " ") If UBound(Temp) = 1 Then TargetFileName = Trim$(Temp(0)) SourceFolder = IIf(Right(Trim$(Temp(1)), 1) = "\", Trim$(Temp(1)), Trim$(Temp(1) & "\")) If ((IsFolderExist(SourceFolder) = True) And (Right$(TargetFileName, 4) = FileType)) Then If GetFileList(SourceFolder) > 0 Then Call MergeCSV Call OutputData(TargetFileName) MsgBox "OK" End If End If Else MsgBox "Command Count Error !" & vbCrLf & Command End If Else MsgBox "Command is Empty !" End If Erase FileNameArray, Tmp End End Sub Private Function GetFileList(strFolderName As String) As Integer Dim TempString As String, ExtendName As String Dim varFSO As Variant, varFolder As Variant, varFile As Variant Dim i As Integer GetFileList = 0: i = 0 Set varFSO = CreateObject("Scripting.FileSystemObject") Set varFolder = varFSO.GetFolder(strFolderName) For Each varFile In varFolder.Files TempString = Trim(Mid(varFile, InStrRev(varFile, "\") + 1)) If InStr(TempString, ".") <> 0 Then ExtendName = Trim$(Mid$(TempString, InStrRev(TempString, "."))) If UCase$(ExtendName) = UCase$(FileType) Then ReDim Preserve FileNameArray(i) FileNameArray(i) = varFile i = i + 1 End If End If Next GetFileList = i End Function Private Sub MergeCSV() Dim TempString As String Dim FileNum As Integer, i As Integer, j As Integer ReDim Tmp(0) For i = 0 To UBound(FileNameArray) FileNum = FreeFile: j = 0 Open FileNameArray(i) For Input As #FileNum Do While Not EOF(FileNum) Line Input #FileNum, TempString If i = 0 Then ReDim Preserve Tmp(j) Tmp(j) = Tmp(j) & TempString j = j + 1 DoEvents Loop Close #FileNum DoEvents Next i End Sub Private Sub OutputData(TF As String) Dim FileNum As Integer, i As Integer FileNum = FreeFile: i = 0 Open TF For Output As #FileNum For i = 0 To UBound(Tmp) Print #FileNum, Tmp(i) Next i Close #FileNum End Sub Public Function IsFolderExist(strFolderName As String) As Boolean Dim varFSO As Variant, TempString As String Set varFSO = CreateObject("Scripting.FileSystemObject") IsFolderExist = varFSO.FolderExists(strFolderName) Set varFSO = Nothing End Function