00001
00002
00003
00004
00005
00006 #include "stdafx.h"
00007 #include "FdmApp.h"
00008 #include "vmsBatchList.h"
00009
00010 #ifdef _DEBUG
00011 #undef THIS_FILE
00012 static char THIS_FILE[]=__FILE__;
00013 #define new DEBUG_NEW
00014 #endif
00015
00016 vmsBatchList::vmsBatchList()
00017 {
00018
00019 }
00020
00021 vmsBatchList::~vmsBatchList()
00022 {
00023
00024 }
00025
00026 bool vmsBatchList::Create(LPCSTR pszTemplate, LPCSTR pszNumbers, char chStart, char chEnd)
00027 {
00028 m_v.clear ();
00029
00030 if (pszNumbers == NULL || strstr (pszTemplate, "(*)") == NULL)
00031 return CreateAZBatch (pszTemplate, chStart, chEnd);
00032
00033 BOOL bAZ = strstr (pszTemplate, "(*a)") || strstr (pszTemplate, "(*A)");
00034
00035 while (*pszNumbers)
00036 {
00037 int nStart, nEnd, nStep = 1, nWB = 1;
00038
00039 #define skip_digits while (*pszNumbers >= '0' && *pszNumbers <= '9') pszNumbers++;
00040 #define skip_spaces while (*pszNumbers == ' ') pszNumbers++;
00041 #define skip_number {skip_digits; skip_spaces;}
00042 #define check_nz if (*pszNumbers == 0) return false;
00043
00044 nStart = nEnd = atoi (pszNumbers);
00045 skip_number;
00046
00047 if (*pszNumbers == 0 || *pszNumbers == ',') {
00048 if (*pszNumbers) {
00049
00050 pszNumbers++;
00051 skip_spaces;
00052 }
00053 }
00054 else {
00055 if (*pszNumbers == '-')
00056 {
00057 pszNumbers++;
00058 skip_spaces;
00059 check_nz;
00060
00061
00062 nEnd = atoi (pszNumbers);
00063 skip_number;
00064 }
00065
00066 while (*pszNumbers && *pszNumbers != ',') {
00067
00068 char chWhat = *pszNumbers++;
00069 skip_spaces;
00070
00071 int nValue = atoi (pszNumbers);
00072 skip_number;
00073
00074 switch (chWhat) {
00075
00076 case BATCHLIST_STEP_SYMBOL: nStep = nValue; break;
00077
00078 case BATCHLIST_WILDCARD_SYMBOL: nWB = nValue; break;
00079 default: return false;
00080 }
00081 }
00082
00083 if (nEnd < nStart || nStep == 0)
00084 return false;
00085
00086 if (*pszNumbers == ',') {
00087 pszNumbers++;
00088 skip_spaces;
00089 }
00090 }
00091
00092 for (int n = nStart; n <= nEnd; n += nStep)
00093 {
00094 CString str = pszTemplate;
00095 CString strN;
00096 strN.Format ("%d", n);
00097 int j = nWB - strN.GetLength ();
00098 while (j-- > 0) strN.Insert (0, '0');
00099 str.Replace ("(*)", strN);
00100
00101 if (bAZ)
00102 CreateAZBatch (str, chStart, chEnd);
00103 else
00104 m_v.add (str);
00105 }
00106 }
00107
00108 return true;
00109 }
00110
00111 int vmsBatchList::get_ResultCount()
00112 {
00113 return m_v.size ();
00114 }
00115
00116 LPCSTR vmsBatchList::get_Result(int nIndex)
00117 {
00118 return m_v [nIndex];
00119 }
00120
00121 bool vmsBatchList::CreateAZBatch(LPCSTR pszTemplate, char chStart, char chEnd)
00122 {
00123 for (char c = chStart; c <= chEnd; c++)
00124 {
00125 CString str = pszTemplate;
00126 CString strA = c;
00127 CString stra = c;
00128 strA.MakeUpper ();
00129 stra.MakeLower ();
00130
00131 str.Replace ("(*A)", strA);
00132 str.Replace ("(*a)", stra);
00133
00134 m_v.add (str);
00135 }
00136
00137 return true;
00138 }
00139
00140 void vmsBatchList::Clear()
00141 {
00142 m_v.clear ();
00143 }