Run external report

Questions regarding syntax

Run external report

Postby GaryVass » Sun Jan 03, 2010 5:05 am

Hi...

I have generated a report using Ireports (part of the jasper reporting set of programs) that connects to Mysql. The report gets the data, and formats it nicely, but how do I get it to run on command from kbasic?

I need to have the kbasic program run a report to display information as needed by the user. SO, how do I code in Kbasic to execute an external program (Ireport) so that it can be displayed?

NOTE: Ireports uses Java

Thanks
GaryVass
 
Posts: 65
Joined: Mon Nov 19, 2007 6:53 am

Re: Run external report

Postby Slowdown » Sun Jan 03, 2010 5:26 am

From my head and not tested,
Code: Select all
dim ReturnValue as Integer
ReturnValue = Shell ("c:\program files\ireport.exe")

replace "c:\program files\............" in the complete path and filename with extension
of the program you want run.
For more info see http://www.kbasic.com/doku.php?id=lrbuiltins#shell
Regards
Slowdown for now i'm back
Slowdown
 
Posts: 347
Joined: Sat May 02, 2009 6:48 pm
Location: Netherlands

Re: Run external report

Postby GaryVass » Mon Oct 25, 2010 11:25 am

Ok, I have tried the Shell command... it would probably work for another program, but not the report writer I am using (see http://reportman.sourceforge.net/)


They have a module for VB and sample code to call the module / report program, pasted below, that i have tried, but Kbasic does not like it (besides, I want to be able to compile for both LInux and Windows).... (and a way to call it in C, but I don't know C, and am unsure that would work from kbasic???)

Would anyone know how to make this work in kbasic? In both Linux / Windows, or at least a windows and a linux version?

rpreportman.bas module code:

Attribute VB_Name = "reportmanapi"
Public Declare Function rp_new Lib "Reportman.ocx" As Long
Public Declare Function rp_open Lib "Reportman.ocx" (ByVal filename As String) As Long
Public Declare Function rp_close Lib "Reportman.ocx" (ByVal hreport As Long) As Long
Public Declare Function rp_execute Lib "Reportman.ocx" (ByVal hreport As Long, ByVal outputfilename As String, ByVal Metafile As Long, ByVal Compressed As Long) As Long
Public Declare Function rp_executeremote_report Lib "Reportman.ocx" (ByVal hreport As Long, ByVal hostname As String, ByVal port As Long, ByVal user As String,ByVal password As String,ByVal aliasname As String,ByVal reportname As String,ByVal outputfilename As String,ByVal metafile As Long,ByVal Compressed As Long) As Long
Public Declare Function rp_executeremote Lib "Reportman.ocx" (ByVal hreport As Long, ByVal hostname As String, ByVal port As Long, ByVal user As String,ByVal password As String,ByVal aliasname As String,ByVal reportname As String,ByVal outputfilename As String,ByVal metafile As Long,ByVal Compressed As Long) As Long
Public Declare Function rp_getremoteparams Lib "Reportman.ocx" (ByVal hreport As Long, ByVal hostname As String, ByVal port As Long, ByVal user As String,ByVal password As String,ByVal aliasname As String,ByVal reportname As String) As Long
Public Declare Function rp_lasterror Lib "Reportman.ocx" () As String
Public Declare Function rp_preview Lib "Reportman.ocx" (ByVal hreport As Long, ByVal title As String) As Long
Public Declare Function rp_print Lib "Reportman.ocx" (ByVal hreport As Long, ByVal title As String, ByVal ShowProgress As Long, ByVal ShowPrintDialog As Long) As Long
Public Declare Function rp_setparamvalue Lib "Reportman.ocx" (ByVal hreport As Long, ByVal paramname As String, ByVal paramtype As Long, ByVal paramvalue As Long) As Long
Public Declare Function rp_setparamvaluevar Lib "Reportman.ocx" (ByVal hreport As Long, ByVal paramname As String, ByVal paramvalue As Variant) As Long
Public Declare Function rp_getparamcount Lib "Reportman.ocx" (ByVal hreport As Long, ByRef paramcount As Long) As Long
Public Declare Function rp_getparamname Lib "Reportman.ocx" (ByVal hreport As Long, ByVal index as Long, ByVal abuffer As String) As Long
Public Declare Function rp_setadoconnectionstring Lib "Reportman.ocx" (ByVal hreport As Long, ByVal conname As String, ByVal constring As String) As Long
Public Declare Function rp_previewremote Lib "Reportman.ocx" (ByVal hostname As String, ByVal port As Long, ByVal user As String,ByVal password As String,ByVal aliasname As String,ByVal reportname As String,ByVal title As String) As Long
Public Declare Function rp_previewremote_report Lib "Reportman.ocx" (ByVal hreport As Long,ByVal hostname As String, ByVal port As Long, ByVal user As String,ByVal password As String,ByVal aliasname As String,ByVal reportname As String,ByVal title As String) As Long
Public Declare Function rp_printremote Lib "Reportman.ocx" (ByVal hostname As String, ByVal port As Long, ByVal user As String,ByVal password As String,ByVal aliasname As String,ByVal reportname As String,ByVal title As String) As Long
Public Declare Function rp_printremote_report Lib "Reportman.ocx" (ByVal hreport As Long,ByVal hostname As String, ByVal port As Long, ByVal user As String,ByVal password As String,ByVal aliasname As String,ByVal reportname As String,ByVal title As String) As Long

and the code to call it from the VB (kbasic) program:

Dim ares As Long
Dim Avar As Variant

rhan = rp_open("samplevb.rep")
If rhan = 0 Then
Text1.Text = rp_lasterror
Else
Avar = "TESTING PARAM"
ares = rp_setparamvaluevar(rhan, "PARAMETER1", Avar)
If ares = 0 Then
Text1.Text = rp_lasterror
Else
ares = rp_preview(rhan, "Hello from VB")
End If
rp_close (rhan)
End If
GaryVass
 
Posts: 65
Joined: Mon Nov 19, 2007 6:53 am

Re: Run external report

Postby pappawinni » Mon Oct 25, 2010 8:05 pm

Hi Gary

think - in the Declare statements you have to use "Integer" instead of "long" and "Cstring" instead of "String"

/Winni
Pappa makes everything what otherwise none likes :)
pappawinni
 
Posts: 192
Joined: Tue Jan 19, 2010 11:27 pm
Location: Germany

Re: Run external report

Postby GaryVass » Mon Oct 25, 2010 11:06 pm

ok... I know the integer one (I changed it back before posting, as I was unsure of all the changes needed)... the other one I missed...

I will change those and see if that works..

Ok, for some strange reason after changing the second line to declare an Integer, I get an error about the type variant is not allowed???
GaryVass
 
Posts: 65
Joined: Mon Nov 19, 2007 6:53 am


Return to Coding Questions

cron