Search the Community
Showing results for tags 'streams'.
Found 2 results
-
Hi, I've been writing an app that takes a data feed from Stdin, and while I have it working using the code below, which works fine if you are running it on the commandline ie sendstuff | MyApp However I was trying to get the App to run inside the IDE by first piping the output to a file sendstuff > xxx and then in the run params having "< xxx", but it doesnt see the input as Stdin and you get a stream size of -1. Anyone got any ideas how to be ablue to simulate the stdin properly so I can step through the code in the IDE, debugging via writeln really sucks. Its a windows app atm, will eventually want to expand it so its windows/linux. Im using Delphi 12.2 John. var StdInHandle: THandle; StdInStream: TStream; Buffer: TBytes; BytesRead: Integer; begin StdInHandle := GetStdHandle(STD_INPUT_HANDLE); // Ensure the handle is valid if StdInHandle = INVALID_HANDLE_VALUE then begin WriteErr('Invalid standard input handle.'); Exit; end; try // Wrap the handle in a THandleStream for easier reading StdInStream := THandleStream.Create(StdInHandle); while StdInStream.Position < StdInStream.Size do begin SetLength(Buffer, StdInStream.Size); BytesRead := StdInStream.Read(Buffer, StdInStream.Size); // do stuff end;
-
I'm using an MS SQL database to store large files in a table. The files are too large for binding to a field directly. It has to go through a command just like the update to get it into the database. No exception is raised but the function returns false. I am finding it difficult to find an answer with Google search. Any help would be apprciated. RIMSDBFireDac.StartTransaction; try with DCaseAttach do begin FireDacQuery.SQL.Text := 'SELECT :p = ''D:\TEMP\TEMP.MP4'' FROM caseattach WHERE id = :id'; FireDacQuery.Params[0].DataType := ftStream; FireDacQuery.Params[0].FDDataType := dtHBFile; FireDacQuery.Params[0].ParamType := ptOutput; FireDacQuery.Params[0].StreamMode := smOpenRead; FireDacQuery.Params[1].AsInteger := CaseN; if FireDacQuery.OpenOrExecute then FireDacQuery.Params[0].AsStream.Read(Buffer, AttachSize) else ErrorMsg('OpenOrExecute failed.'); end; RIMSDBFireDac.Commit; except on E: Exception do begin ErrorMsg('<PullImageFromDB on pulling photo> ' + E.Message); RIMSDBFireDac.Rollback; end; end;