[453] | 1 | //kt -- Modified with SourceScanner on 8/8/2007
|
---|
| 2 | unit uODBase;
|
---|
| 3 |
|
---|
| 4 | interface
|
---|
| 5 |
|
---|
| 6 | uses
|
---|
| 7 | Classes, ORFn, uConst;
|
---|
| 8 |
|
---|
| 9 | { Order Checking }
|
---|
| 10 | function AddFillerAppID(const AnID: string): Boolean;
|
---|
| 11 | procedure ClearFillerAppList;
|
---|
| 12 |
|
---|
| 13 | { Ordering Environment }
|
---|
| 14 | procedure SetOrderFormIDOnCreate(AFormID: Integer);
|
---|
| 15 | function OrderFormIDOnCreate: Integer;
|
---|
| 16 | procedure SetOrderEventTypeOnCreate(AType: Char);
|
---|
| 17 | function OrderEventTypeOnCreate: Char;
|
---|
| 18 | procedure SetOrderEventIDOnCreate(AnEvtID: integer);
|
---|
| 19 | function OrderEventIDOnCreate: integer;
|
---|
| 20 | procedure SetOrderEventNameOnCreate(AnEvtNm: string);
|
---|
| 21 | function OrderEventNameOnCreate: string;
|
---|
| 22 | function GetKeyVars: string;
|
---|
| 23 | procedure PopKeyVars(NumLevels: Integer = 1);
|
---|
| 24 | procedure PushKeyVars(const NewVals: string);
|
---|
| 25 | procedure ExpandOrderObjects(var Txt: string; var ContainsObjects: boolean; msg: string = '');
|
---|
| 26 |
|
---|
| 27 | implementation
|
---|
| 28 |
|
---|
| 29 | uses
|
---|
| 30 | dShared, Windows, rTemplates,
|
---|
| 31 | DKLang //kt
|
---|
| 32 | ;
|
---|
| 33 |
|
---|
| 34 | var
|
---|
| 35 | uOrderEventType: Char;
|
---|
| 36 | uOrderEventID: Integer;
|
---|
| 37 | uOrderEventName: string;
|
---|
| 38 | uOrderFormID: Integer;
|
---|
| 39 | uFillerAppID: TStringList;
|
---|
| 40 | uKeyVarList: TStringList;
|
---|
| 41 |
|
---|
| 42 | { Order Checking }
|
---|
| 43 |
|
---|
| 44 | function AddFillerAppID(const AnID: string): Boolean;
|
---|
| 45 | begin
|
---|
| 46 | Result := False;
|
---|
| 47 | if uFillerAppID.IndexOf(AnID) < 0 then
|
---|
| 48 | begin
|
---|
| 49 | Result := True;
|
---|
| 50 | uFillerAppID.Add(AnID);
|
---|
| 51 | end;
|
---|
| 52 | end;
|
---|
| 53 |
|
---|
| 54 | procedure ClearFillerAppList;
|
---|
| 55 | begin
|
---|
| 56 | uFillerAppID.Clear;
|
---|
| 57 | end;
|
---|
| 58 |
|
---|
| 59 | { Ordering Environment }
|
---|
| 60 |
|
---|
| 61 | procedure SetOrderFormIDOnCreate(AFormID: Integer);
|
---|
| 62 | begin
|
---|
| 63 | uOrderFormID := AFormID;
|
---|
| 64 | end;
|
---|
| 65 |
|
---|
| 66 | function OrderFormIDOnCreate: Integer;
|
---|
| 67 | begin
|
---|
| 68 | Result := uOrderFormID;
|
---|
| 69 | end;
|
---|
| 70 |
|
---|
| 71 | procedure SetOrderEventTypeOnCreate(AType: Char);
|
---|
| 72 | begin
|
---|
| 73 | uOrderEventType := AType;
|
---|
| 74 | end;
|
---|
| 75 |
|
---|
| 76 | function OrderEventTypeOnCreate: Char;
|
---|
| 77 | begin
|
---|
| 78 | Result := uOrderEventType;
|
---|
| 79 | end;
|
---|
| 80 |
|
---|
| 81 | procedure SetOrderEventIDOnCreate(AnEvtID: Integer);
|
---|
| 82 | begin
|
---|
| 83 | uOrderEventID := AnEvtID;
|
---|
| 84 | end;
|
---|
| 85 |
|
---|
| 86 | procedure SetOrderEventNameOnCreate(AnEvtNm: string);
|
---|
| 87 | begin
|
---|
| 88 | uOrderEventName := AnEvtNm;
|
---|
| 89 | end;
|
---|
| 90 |
|
---|
| 91 | function OrderEventNameOnCreate: string;
|
---|
| 92 | begin
|
---|
| 93 | Result := uOrderEventName;
|
---|
| 94 | end;
|
---|
| 95 |
|
---|
| 96 | function OrderEventIDOnCreate: integer;
|
---|
| 97 | begin
|
---|
| 98 | Result := uOrderEventID;
|
---|
| 99 | end;
|
---|
| 100 |
|
---|
| 101 | function GetKeyVars: string;
|
---|
| 102 | begin
|
---|
| 103 | Result := '';
|
---|
| 104 | with uKeyVarList do if Count > 0 then Result := Strings[Count - 1];
|
---|
| 105 | end;
|
---|
| 106 |
|
---|
| 107 | procedure PopKeyVars(NumLevels: Integer = 1);
|
---|
| 108 | begin
|
---|
| 109 | with uKeyVarList do while (NumLevels > 0) and (Count > 0) do
|
---|
| 110 | begin
|
---|
| 111 | Delete(Count - 1);
|
---|
| 112 | Dec(NumLevels);
|
---|
| 113 | end;
|
---|
| 114 | end;
|
---|
| 115 |
|
---|
| 116 | procedure PushKeyVars(const NewVals: string);
|
---|
| 117 | var
|
---|
| 118 | i: Integer;
|
---|
| 119 | x: string;
|
---|
| 120 | begin
|
---|
| 121 | if uKeyVarList.Count > 0 then x := uKeyVarList[uKeyVarList.Count - 1] else x := '';
|
---|
| 122 | for i := 1 to MAX_KEYVARS do
|
---|
| 123 | if Piece(NewVals, U, i) <> '' then SetPiece(x, U, i, Piece(NewVals, U, i));
|
---|
| 124 | uKeyVarList.Add(x);
|
---|
| 125 | end;
|
---|
| 126 |
|
---|
| 127 | procedure ExpandOrderObjects(var Txt: string; var ContainsObjects: boolean; msg: string = '');
|
---|
| 128 | var
|
---|
| 129 | ObjList: TStringList;
|
---|
| 130 | Err: TStringList;
|
---|
| 131 | i, j, k, oLen: integer;
|
---|
| 132 | obj, ObjTxt: string;
|
---|
| 133 |
|
---|
| 134 | const
|
---|
| 135 | CRDelim = #13;
|
---|
| 136 | //TC_BOILER_ERR = 'Order Boilerplate Object Error'; <-- original line. //kt 8/8/2007
|
---|
| 137 | //TX_BOILER_ERR = 'Contact IRM and inform them about this error.' + CRLF + <-- original line. //kt 8/8/2007
|
---|
| 138 | // 'Make sure you give them the name of the quick' + CRLF + <-- original line. //kt 8/8/2007
|
---|
| 139 | // 'order that you are processing.' ; <-- original line. //kt 8/8/2007
|
---|
| 140 |
|
---|
| 141 | var //kt added
|
---|
| 142 | TC_BOILER_ERR : string; //kt added
|
---|
| 143 | TX_BOILER_ERR : string; //kt added
|
---|
| 144 |
|
---|
| 145 | begin
|
---|
| 146 | TC_BOILER_ERR := DKLangConstW('uODBase_Order_Boilerplate_Object_Error'); //kt added 8/8/2007
|
---|
| 147 | TX_BOILER_ERR := DKLangConstW('uODBase_Contact_IRM_and_inform_them_about_this_errorx') + CRLF + //kt added 8/8/2007
|
---|
| 148 | DKLangConstW('uODBase_Make_sure_you_give_them_the_name_of_the_quick') + CRLF + //kt added 8/8/2007
|
---|
| 149 | DKLangConstW('uODBase_order_that_you_are_processingx') ; //kt added 8/8/2007
|
---|
| 150 | ObjList := TStringList.Create;
|
---|
| 151 | try
|
---|
| 152 | Err := nil;
|
---|
| 153 | if(not dmodShared.BoilerplateOK(Txt, CRDelim, ObjList, Err)) and (assigned(Err)) then
|
---|
| 154 | begin
|
---|
| 155 | try
|
---|
| 156 | Err.Add(CRLF + TX_BOILER_ERR);
|
---|
| 157 | InfoBox(Err.Text, TC_BOILER_ERR, MB_OK + MB_ICONERROR);
|
---|
| 158 | finally
|
---|
| 159 | Err.Free;
|
---|
| 160 | end;
|
---|
| 161 | end;
|
---|
| 162 | if(ObjList.Count > 0) then
|
---|
| 163 | begin
|
---|
| 164 | ContainsObjects := True;
|
---|
| 165 | GetTemplateText(ObjList);
|
---|
| 166 | i := 0;
|
---|
| 167 | while (i < ObjList.Count) do
|
---|
| 168 | begin
|
---|
| 169 | if(pos(ObjMarker, ObjList[i]) = 1) then
|
---|
| 170 | begin
|
---|
| 171 | obj := copy(ObjList[i], ObjMarkerLen+1, MaxInt);
|
---|
| 172 | if(obj = '') then break;
|
---|
| 173 | j := i + 1;
|
---|
| 174 | while (j < ObjList.Count) and (pos(ObjMarker, ObjList[j]) = 0) do
|
---|
| 175 | inc(j);
|
---|
| 176 | if((j - i) > 2) then
|
---|
| 177 | begin
|
---|
| 178 | ObjTxt := '';
|
---|
| 179 | for k := i+1 to j-1 do
|
---|
| 180 | ObjTxt := ObjTxt + #13 + ObjList[k];
|
---|
| 181 | end
|
---|
| 182 | else
|
---|
| 183 | ObjTxt := ObjList[i+1];
|
---|
| 184 | i := j;
|
---|
| 185 | obj := '|' + obj + '|';
|
---|
| 186 | oLen := length(obj);
|
---|
| 187 | repeat
|
---|
| 188 | j := pos(obj, Txt);
|
---|
| 189 | if(j > 0) then
|
---|
| 190 | begin
|
---|
| 191 | delete(Txt, j, OLen);
|
---|
| 192 | insert(ObjTxt, Txt, j);
|
---|
| 193 | end;
|
---|
| 194 | until(j = 0);
|
---|
| 195 | end
|
---|
| 196 | else
|
---|
| 197 | inc(i);
|
---|
| 198 | end
|
---|
| 199 | end;
|
---|
| 200 | finally
|
---|
| 201 | ObjList.Free;
|
---|
| 202 | end;
|
---|
| 203 | end;
|
---|
| 204 |
|
---|
| 205 | initialization
|
---|
| 206 | uOrderEventType := #0;
|
---|
| 207 | uOrderFormID := 0;
|
---|
| 208 | uOrderEventName := '';
|
---|
| 209 | uFillerAppID := TStringList.Create;
|
---|
| 210 | uKeyVarList := TStringList.Create;
|
---|
| 211 |
|
---|
| 212 | finalization
|
---|
| 213 | uFillerAppID.Free;
|
---|
| 214 | uKeyVarList.Free;
|
---|
| 215 |
|
---|
| 216 | end.
|
---|