Search the Community
Showing results for tags 'pipeline'.
Found 2 results
-
Hi! I am developing a simple editor application in which you can type Pascal code and click the compile button, which will connect cmd.exe in the background and compile a .pas file via freepascalcompiler. I have two separate TMemo components. one for writing source code and a second read-only component for showing compilation messages. To sum up, I want to execute the "fpc file_name. pas" command in the background and then grab the compiled messages and display them on the UI. How can I achieve such behavior? https://github.com/gchapidze/fmx-pascalIDE
-
The following code works perfectly with one task but fails to process one input variable with two tasks, two input variables with three tasks, etc. pipeline := Parallel .Pipeline .Stage( procedure(const input, output: IOmniBlockingCollection) var NewAmt, OldAmt: Currency; aDataObj: TDataObj; aValue: TOmniValue; aDm: TdmRetriever; begin aDm := TdmRetriever.Create(nil); aDm.SetUp(DataPath); aDataObj := TDataObj.Create('', 0, 0); try for aValue in input do // input is a stringlist of AcctNum begin s := aValue.AsString; MySL.Add(s); aDm.qRetrieverNew.SQL.Text := 'SELECT SUM(Amount) AS CurrYrAmt FROM TransBS' + #13 + 'WHERE (dDate <= ' + QuotedStr(ThruDateStr) + ') AND (AcctNum = ' + QuotedStr(s) + ')'; aDm.qRetrieverOld.SQL.Text := 'SELECT SUM(Amount) AS PrevYrAmt FROM TransBS' + #13 + 'WHERE (dDate <= ' + QuotedStr(PrevThruDateStr) + ') AND (AcctNum = ' + QuotedStr(s) + ')'; aDm.qRetrieverNew.Open; aDm.qRetrieverOld.Open; // Everything continues fine with one task; execution continues with first AcctNum // The first AcctNum is not processed below with two tasks // The first and second AcctNum are not processed below with three tasks if not VarIsNull(aDm.qRetrieverNew.FieldByName('CurrYrAmt').AsVariant) then NewAmt := aDm.qRetrieverNew.FieldByName('CurrYrAmt').AsCurrency else NewAmt := 0; if not VarIsNull(aDm.qRetrieverOld.FieldByName('PrevYrAmt').AsVariant) then OldAmt := aDm.qRetrieverOld.FieldByName('PrevYrAmt').AsCurrency else OldAmt := 0; MySL.Add(s + ', ' + CurrToStr(NewAmt) + ', ' + CurrToStr(OldAmt) ); aDataObj.fAcctNum := s; aDataObj.fCurrYr := NewAmt; aDataObj.fPrevYr := OldAmt; if not output.TryAdd(aDataObj) then break; end; aDm.SessionRetriever.CloseDatabase(aDm.dbRetriever); aDm.SessionRetriever.DropConnections; finally aDataObj.Free; aDm.Free; end; end ).NumTasks(aNumTasks) .Stage( The results, as logged to the MySL stringlist, are attached. I have no idea how to fix this. "aDm" is datamodule I create which contains the queries. I have placed the query openingss in a try-except and never received an error. I have placed query.isempty in a while loop since the query for AcctNum 1111 takes about 4 seconds. The answer is probably something simple, but I'm at a loss as to what I am doing wrong. Will appreciate any help. Log.txt
- 9 replies
-
- omnithreadlibrary
- database
-
(and 1 more)
Tagged with: