Subject RE: [IBO] IB_COlumn Assign AV
Author Alan McDonald
> At 02:16 PM 13/01/2005 +1100, you wrote:
>
> >Just looking for a hint here..
> >I have the following code:
> > stRVF :=
> >IB_QConvertToRTF.CreateBlobStream(IB_QConvertToRTF.FieldByName('ANSWER'),
> >bsmRead);
>
> That prepares a Blob column to be *read from* as a stream. If
> you want it
> to be *written to*, you need to make its BlobStreamMode bsmWrite; or if
> you want it to be both, make it bsmReadWrite.
>
> > RichViewUtil.LoadRVFFromStream(AnsRVF);
> > RichViewUtil.SaveRTFToStream(AnsRTF, False);
> >--> IB_QConvertToRTF.FieldByName('ANSWERRTF').Assign(AnsRTF);
> >which AVs on the marked line...
>
> Yup. Change the mode of the receiving stream object and you
> should be fine.
>
> Helen

Just to clarify with pseudo code:
procedure TMain.ConvertRVFtoRTF(Sender: TObject);
var
AnsRTF, AnsRVF : TStream;
bSaved: Boolean;
begin
with dmLocalStore.IB_QConvertToRTF do begin
Open;
while not EOF do begin
// create a read stream and load the stream from blob field 1
AnsRVF :=
IB_QConvertToRTF.CreateBlobStream(IB_QConvertToRTF.FieldByName('ANSWER'),
bsmRead);
// Put the Stream into a control
RichViewUtil.LoadRVFFromStream(AnsRVF);
// Now convert it using the control method for doing so
bSaved := RichViewUtil.SaveRTFToStream(AnsRTF, False);
// Now assign this new stream (created in the conversion method to
blob field 2
IB_QConvertToRTF.FieldByName('ANSWERRTF').Assign(AnsRTF);
dmLocalStore.IB_QConvertToRTF.Next;
end;
Close;
end;
end;

If I create the steam as writeable with
AnsRTF :=
IB_QConvertToRTF.CreateBlobStream(IB_QConvertToRTF.FieldByName('ANSWERRTF'),
bsmWrite);
first, I don't get an error but nothing gets assigned to field 2
If I don't create the writeable stream first, then I get the AV.
If I create the stream as writable, I don't think the other control's method
writes to it.
But I know the conversion works because I can write to a file instead of
assign it to field 2 and it's there.
Where do I make the stream writable in this scenario?
Alan