Skip to main content

Hello,

I´m trying to implement in Visual COBOL the following code (C#):

report.Render("Image", deviceInfo, CreateStream, out warnings);


CreateStream is not a dataitem but a function call... that is, a callback function defined previously as:

private Stream CreateStream(string name, string fileNameExtension, Encoding encoding, string mimeType, bool willSeek) { Stream stream = new MemoryStream(); m_streams.Add(stream); return stream; }

I can´t get the way to translate that type of callback function call as a parameter of a COBOL INVOKE.

This is what I tried, but although it compiles, it doesn´t run (null exception):

INVOKE informe::Render("Image", deviceInfo, CreateStream, warnings).

And this is the definition of my Callback function:

delegate-id CreateStreamHandler.
procedure division using nombre as string, fileExtension as string, codificacion as type Encoding, mimeType as string, willSeek as condition-value
RETURNING stream as type Stream.
end delegate.
 

01 CreateStream type CreateStreamCallBack.

method-id CreateStreamCallBack.
procedure division USING nombre as string, fileExtension as string, codificacion as type Encoding, mimeType as string, willSeek as condition-value
RETURNING stream as type Stream.
SET stream TO New MemoryStream().
INVOKE m_streams::Add(stream).
end method.

The code I´m trying to replicate is located here:

http://msdn.microsoft.com/es-es/library/ms252091.aspx

Kind regards

Hello,

I´m trying to implement in Visual COBOL the following code (C#):

report.Render("Image", deviceInfo, CreateStream, out warnings);


CreateStream is not a dataitem but a function call... that is, a callback function defined previously as:

private Stream CreateStream(string name, string fileNameExtension, Encoding encoding, string mimeType, bool willSeek) { Stream stream = new MemoryStream(); m_streams.Add(stream); return stream; }

I can´t get the way to translate that type of callback function call as a parameter of a COBOL INVOKE.

This is what I tried, but although it compiles, it doesn´t run (null exception):

INVOKE informe::Render("Image", deviceInfo, CreateStream, warnings).

And this is the definition of my Callback function:

delegate-id CreateStreamHandler.
procedure division using nombre as string, fileExtension as string, codificacion as type Encoding, mimeType as string, willSeek as condition-value
RETURNING stream as type Stream.
end delegate.
 

01 CreateStream type CreateStreamCallBack.

method-id CreateStreamCallBack.
procedure division USING nombre as string, fileExtension as string, codificacion as type Encoding, mimeType as string, willSeek as condition-value
RETURNING stream as type Stream.
SET stream TO New MemoryStream().
INVOKE m_streams::Add(stream).
end method.

The code I´m trying to replicate is located here:

http://msdn.microsoft.com/es-es/library/ms252091.aspx

Kind regards

Hi jcamacho, I think you need to make two changes:

1) the parameters in CreateStreamCallBack need to be BY VALUE, so:

method-id CreateStreamCallBack.

procedure division USING BY VALUE nombre as string, fileExtension as string, codificacion as type Encoding, mimeType as string, willSeek as condition-value

2) since the parameter to the 'render' function is actually a method rather than a data item, it needs to be preceded by the keyword 'METHOD' and to provide the object (or type) on which the method is to act, so:

INVOKE informe::Render("Image", deviceInfo, method self::CreateStream, warnings).

I must say I'm surprised that the code in its existing state compiles - I would have expected a compile time error, but maybe I'm missing something.

Let me know if these modifications help.

Regards


Hello,

I´m trying to implement in Visual COBOL the following code (C#):

report.Render("Image", deviceInfo, CreateStream, out warnings);


CreateStream is not a dataitem but a function call... that is, a callback function defined previously as:

private Stream CreateStream(string name, string fileNameExtension, Encoding encoding, string mimeType, bool willSeek) { Stream stream = new MemoryStream(); m_streams.Add(stream); return stream; }

I can´t get the way to translate that type of callback function call as a parameter of a COBOL INVOKE.

This is what I tried, but although it compiles, it doesn´t run (null exception):

INVOKE informe::Render("Image", deviceInfo, CreateStream, warnings).

And this is the definition of my Callback function:

delegate-id CreateStreamHandler.
procedure division using nombre as string, fileExtension as string, codificacion as type Encoding, mimeType as string, willSeek as condition-value
RETURNING stream as type Stream.
end delegate.
 

01 CreateStream type CreateStreamCallBack.

method-id CreateStreamCallBack.
procedure division USING nombre as string, fileExtension as string, codificacion as type Encoding, mimeType as string, willSeek as condition-value
RETURNING stream as type Stream.
SET stream TO New MemoryStream().
INVOKE m_streams::Add(stream).
end method.

The code I´m trying to replicate is located here:

http://msdn.microsoft.com/es-es/library/ms252091.aspx

Kind regards

I made the changes you suggested but it now shows me the following error:

Could not find method "Render" with this Signature.

See attached file.


Hello,

I´m trying to implement in Visual COBOL the following code (C#):

report.Render("Image", deviceInfo, CreateStream, out warnings);


CreateStream is not a dataitem but a function call... that is, a callback function defined previously as:

private Stream CreateStream(string name, string fileNameExtension, Encoding encoding, string mimeType, bool willSeek) { Stream stream = new MemoryStream(); m_streams.Add(stream); return stream; }

I can´t get the way to translate that type of callback function call as a parameter of a COBOL INVOKE.

This is what I tried, but although it compiles, it doesn´t run (null exception):

INVOKE informe::Render("Image", deviceInfo, CreateStream, warnings).

And this is the definition of my Callback function:

delegate-id CreateStreamHandler.
procedure division using nombre as string, fileExtension as string, codificacion as type Encoding, mimeType as string, willSeek as condition-value
RETURNING stream as type Stream.
end delegate.
 

01 CreateStream type CreateStreamCallBack.

method-id CreateStreamCallBack.
procedure division USING nombre as string, fileExtension as string, codificacion as type Encoding, mimeType as string, willSeek as condition-value
RETURNING stream as type Stream.
SET stream TO New MemoryStream().
INVOKE m_streams::Add(stream).
end method.

The code I´m trying to replicate is located here:

http://msdn.microsoft.com/es-es/library/ms252091.aspx

Kind regards

It's difficult to say why it's failing without seeing the whole application.  Is the Render method (in type LocalReport) declared with BY VALUE parameters?


Hello,

I´m trying to implement in Visual COBOL the following code (C#):

report.Render("Image", deviceInfo, CreateStream, out warnings);


CreateStream is not a dataitem but a function call... that is, a callback function defined previously as:

private Stream CreateStream(string name, string fileNameExtension, Encoding encoding, string mimeType, bool willSeek) { Stream stream = new MemoryStream(); m_streams.Add(stream); return stream; }

I can´t get the way to translate that type of callback function call as a parameter of a COBOL INVOKE.

This is what I tried, but although it compiles, it doesn´t run (null exception):

INVOKE informe::Render("Image", deviceInfo, CreateStream, warnings).

And this is the definition of my Callback function:

delegate-id CreateStreamHandler.
procedure division using nombre as string, fileExtension as string, codificacion as type Encoding, mimeType as string, willSeek as condition-value
RETURNING stream as type Stream.
end delegate.
 

01 CreateStream type CreateStreamCallBack.

method-id CreateStreamCallBack.
procedure division USING nombre as string, fileExtension as string, codificacion as type Encoding, mimeType as string, willSeek as condition-value
RETURNING stream as type Stream.
SET stream TO New MemoryStream().
INVOKE m_streams::Add(stream).
end method.

The code I´m trying to replicate is located here:

http://msdn.microsoft.com/es-es/library/ms252091.aspx

Kind regards

I understand the difficulty.

The prototype for the method is:

Microsoft.Reporting.WinForms.Report::Render(format AS string, deviceInfo AS string, createStream AS Microsoft.Reporting.WinForms.CreateStreamCallback, REFERENCE warnings AS Microsoft.Reporting.WinForms.Warning OCCURS ANY)

Thank you for your suggestions. Robert


Hello,

I´m trying to implement in Visual COBOL the following code (C#):

report.Render("Image", deviceInfo, CreateStream, out warnings);


CreateStream is not a dataitem but a function call... that is, a callback function defined previously as:

private Stream CreateStream(string name, string fileNameExtension, Encoding encoding, string mimeType, bool willSeek) { Stream stream = new MemoryStream(); m_streams.Add(stream); return stream; }

I can´t get the way to translate that type of callback function call as a parameter of a COBOL INVOKE.

This is what I tried, but although it compiles, it doesn´t run (null exception):

INVOKE informe::Render("Image", deviceInfo, CreateStream, warnings).

And this is the definition of my Callback function:

delegate-id CreateStreamHandler.
procedure division using nombre as string, fileExtension as string, codificacion as type Encoding, mimeType as string, willSeek as condition-value
RETURNING stream as type Stream.
end delegate.
 

01 CreateStream type CreateStreamCallBack.

method-id CreateStreamCallBack.
procedure division USING nombre as string, fileExtension as string, codificacion as type Encoding, mimeType as string, willSeek as condition-value
RETURNING stream as type Stream.
SET stream TO New MemoryStream().
INVOKE m_streams::Add(stream).
end method.

The code I´m trying to replicate is located here:

http://msdn.microsoft.com/es-es/library/ms252091.aspx

Kind regards

I understand the difficulty.

The prototype for the method is:

Microsoft.Reporting.WinForms.Report::Render(format AS string, deviceInfo AS string, createStream AS Microsoft.Reporting.WinForms.CreateStreamCallback, REFERENCE warnings AS Microsoft.Reporting.WinForms.Warning OCCURS ANY)

Thank you for your suggestions. Robert


Hello,

I´m trying to implement in Visual COBOL the following code (C#):

report.Render("Image", deviceInfo, CreateStream, out warnings);


CreateStream is not a dataitem but a function call... that is, a callback function defined previously as:

private Stream CreateStream(string name, string fileNameExtension, Encoding encoding, string mimeType, bool willSeek) { Stream stream = new MemoryStream(); m_streams.Add(stream); return stream; }

I can´t get the way to translate that type of callback function call as a parameter of a COBOL INVOKE.

This is what I tried, but although it compiles, it doesn´t run (null exception):

INVOKE informe::Render("Image", deviceInfo, CreateStream, warnings).

And this is the definition of my Callback function:

delegate-id CreateStreamHandler.
procedure division using nombre as string, fileExtension as string, codificacion as type Encoding, mimeType as string, willSeek as condition-value
RETURNING stream as type Stream.
end delegate.
 

01 CreateStream type CreateStreamCallBack.

method-id CreateStreamCallBack.
procedure division USING nombre as string, fileExtension as string, codificacion as type Encoding, mimeType as string, willSeek as condition-value
RETURNING stream as type Stream.
SET stream TO New MemoryStream().
INVOKE m_streams::Add(stream).
end method.

The code I´m trying to replicate is located here:

http://msdn.microsoft.com/es-es/library/ms252091.aspx

Kind regards

OK,

I finally made it working. I modified the INVOKE TO use the proper method name, not the dataitem.

INVOKE informe::Render("Image", deviceInfo, method self::CreateStreamCallback, warnings).

Which makes me think... Do I still need to have this method as an implementation for a delegate?

Kind regards


Hello,

I´m trying to implement in Visual COBOL the following code (C#):

report.Render("Image", deviceInfo, CreateStream, out warnings);


CreateStream is not a dataitem but a function call... that is, a callback function defined previously as:

private Stream CreateStream(string name, string fileNameExtension, Encoding encoding, string mimeType, bool willSeek) { Stream stream = new MemoryStream(); m_streams.Add(stream); return stream; }

I can´t get the way to translate that type of callback function call as a parameter of a COBOL INVOKE.

This is what I tried, but although it compiles, it doesn´t run (null exception):

INVOKE informe::Render("Image", deviceInfo, CreateStream, warnings).

And this is the definition of my Callback function:

delegate-id CreateStreamHandler.
procedure division using nombre as string, fileExtension as string, codificacion as type Encoding, mimeType as string, willSeek as condition-value
RETURNING stream as type Stream.
end delegate.
 

01 CreateStream type CreateStreamCallBack.

method-id CreateStreamCallBack.
procedure division USING nombre as string, fileExtension as string, codificacion as type Encoding, mimeType as string, willSeek as condition-value
RETURNING stream as type Stream.
SET stream TO New MemoryStream().
INVOKE m_streams::Add(stream).
end method.

The code I´m trying to replicate is located here:

http://msdn.microsoft.com/es-es/library/ms252091.aspx

Kind regards

Hi, I'm not sure I understand the question.  If you're talking about the CreateStreamCallback method, I think the answer is yes, as you need to supply some code which will be the target of the delegate passed to the 'Render' method.  


Hello,

I´m trying to implement in Visual COBOL the following code (C#):

report.Render("Image", deviceInfo, CreateStream, out warnings);


CreateStream is not a dataitem but a function call... that is, a callback function defined previously as:

private Stream CreateStream(string name, string fileNameExtension, Encoding encoding, string mimeType, bool willSeek) { Stream stream = new MemoryStream(); m_streams.Add(stream); return stream; }

I can´t get the way to translate that type of callback function call as a parameter of a COBOL INVOKE.

This is what I tried, but although it compiles, it doesn´t run (null exception):

INVOKE informe::Render("Image", deviceInfo, CreateStream, warnings).

And this is the definition of my Callback function:

delegate-id CreateStreamHandler.
procedure division using nombre as string, fileExtension as string, codificacion as type Encoding, mimeType as string, willSeek as condition-value
RETURNING stream as type Stream.
end delegate.
 

01 CreateStream type CreateStreamCallBack.

method-id CreateStreamCallBack.
procedure division USING nombre as string, fileExtension as string, codificacion as type Encoding, mimeType as string, willSeek as condition-value
RETURNING stream as type Stream.
SET stream TO New MemoryStream().
INVOKE m_streams::Add(stream).
end method.

The code I´m trying to replicate is located here:

http://msdn.microsoft.com/es-es/library/ms252091.aspx

Kind regards

I got rid of the delegate and just renamed CreateStreamCallback method to CreateStream. Everything worked. Just I needed to learn the method parameter syntax.


Hello,

I´m trying to implement in Visual COBOL the following code (C#):

report.Render("Image", deviceInfo, CreateStream, out warnings);


CreateStream is not a dataitem but a function call... that is, a callback function defined previously as:

private Stream CreateStream(string name, string fileNameExtension, Encoding encoding, string mimeType, bool willSeek) { Stream stream = new MemoryStream(); m_streams.Add(stream); return stream; }

I can´t get the way to translate that type of callback function call as a parameter of a COBOL INVOKE.

This is what I tried, but although it compiles, it doesn´t run (null exception):

INVOKE informe::Render("Image", deviceInfo, CreateStream, warnings).

And this is the definition of my Callback function:

delegate-id CreateStreamHandler.
procedure division using nombre as string, fileExtension as string, codificacion as type Encoding, mimeType as string, willSeek as condition-value
RETURNING stream as type Stream.
end delegate.
 

01 CreateStream type CreateStreamCallBack.

method-id CreateStreamCallBack.
procedure division USING nombre as string, fileExtension as string, codificacion as type Encoding, mimeType as string, willSeek as condition-value
RETURNING stream as type Stream.
SET stream TO New MemoryStream().
INVOKE m_streams::Add(stream).
end method.

The code I´m trying to replicate is located here:

http://msdn.microsoft.com/es-es/library/ms252091.aspx

Kind regards

Ah yes, you don't need to define your own delegate.  Glad you got it working...