Archive

Posts Tagged ‘scripting’

Window View – The Next BIG thing in Sunset Reports

December 15, 2015 1 comment

Coming in the next version of Sunset Reports is “Window View”.   Currently you can print, export, and print preview a report.  With “Window View”, your report becomes a window for viewing on the screen only.   The features of this new view include:

  1. Display your report as a window on the screen
  2. The window can be interactive using the scripts you design in the report designer.   There are numerous possibilities here.  Drilldown reports, menus, etc.   This can be your user interface to the reports you want to give to a user.   Users don’t even have to see the functions of Sunset Reports to see the reports they want or you want to give them.  You can launch other reports in Window View or Print Preview.
  3. The window is automatically sized to the page size of the report design so you can control the window size.  Make it as small or large as you want.  Include any of the report objects.   Use a Label with a OnClick script to create a button.
  4. You can set a time for the window to refresh.  This means your report will be updated periodically automatically.  The update time can be as little as 1 second.  So now your report will update in real time showing real time data.
  5. If your report has more than one page, and if you set an window refresh time, the pages of the report will cycle to that time, and when the first page comes back up, the report will be refreshed with new data.   This feature can be used for slide shows with real time data.

The following figure shows a Window View of a report design.  This design is intended to work as a menu system.   It has a clock that is updated every second.   The five items on the right are labels with click events to perform functions.   This example is included in the sample reports file included with the product.   You can actually create your own application with this feature.

DemoMenu

Additional Samples

August 28, 2013 Leave a comment

With the release of 1.95, we have included a second set of samples in the Samples2 file.   These samples are more advanced and demonstrate the powerful features of Windows mode and scripts.  You can copy these reports and modify them as you want. Included are:

  • Digital Clock – This report when viewed in Window View will show the current time and update each second.
  • Current US Radar – This report will display the current US radar map.   If viewed in Window View, it will update automatically every 60 seconds by the use of the numeric parameter, WindowViewTimer.  The report can be easily modified to show a different region.
  • Disk Space – This report uses gauges and a script that reads the drive space on disk C and shows disk space used and disk space free.
  • Edit Global and User Parameters – This unique report is actually an interactive form showing how you can change data and update the global and user parameters.  Reports are not read only anymore.
  • Get IP – This report will get your current Internet IP address.   It will check it against a previous value created by this report and stored in a Global Parameter.   If the IP is different, the report runs.  If it is the same, the report will not produce any output.   This is useful if you want to email or text yourself if your IP changes.  This shows you how you can save data to the parameters.  Solves dynamic IP issues.
  • Get Web Page – This report shows you how easy it is to capture a Web Page and load the HTML into a Rich Text Control.
  • Hurricane Report – Captures an image from the internet.
  • Main Menu – The report is actually a customizable main menu for Sunset Reports.   You can use this as a starting point for your own menu.   Make sure you set the preference for the starting form to be “Main Menu Report Definition”.   If you need to get back to the regular program interface, close this menu holding down the Ctrl key.
  • Photo Album Slide Show – This report shows you how to display all the images in a folder in a report.   The script contains the code to create a file list from the parameter “Picture Folder”.  The file list is stored in a file named Index.XML.  This file is then used as the data source by using the report parameter XML Data Path.  You can change the design of the report to show one picture on a page.  Then using Window View, the pictures will cycle.

Directory List Report

May 18, 2012 Leave a comment

Here is a sample report with a script that will list the contents of a folder on a hard drive.

First start with a blank report.   It will be unbound (no data source).   The data source will be created in a script.   On the report add a table and name each cell as follows:   Add a second table in the report header to name the columns.   And then finally add a label control for a title.

Now for the script that will run this report.

You set the variable “directory” to the folder you want to get a file list of.    You can modify this so it is a report parameter, but to keep things simple now, just hardcode the folder.   The rest of the script creates an array with file information and assigns the array to the datasource of the report.   Then each cell in the table needs to be bound to an element of the array.   Finally the title is set to the string variable “directory”.

The resulting report looks like this when previewed:

You can download this sample report HERE.

Tag Property

May 11, 2012 Leave a comment

Within the Sunset Report’s report designer, each object has a “Tag” property.   This property allows you to add some unique information that can be accessed via scripts.   This could be an id, or actually a data field if the report has a data source.   With this tag property all kinds of possibilities exist with scripts.

Unbound Report with Scripts

May 10, 2012 Leave a comment

Here is an example of what you can do with scripts in a report.   First start with a blank report design with no data source.    Drag a chart object onto the design surface as shown in the figure.

Next add the following code in the scripts tab….

'Define a class to represent an individual record with properties to be data source fields
Public Class Record
  Dim _id As Integer
  Dim _txt As String
  Dim _num as double
  Public Sub New(ByVal id As Integer, ByVal txt As String, ByVal num As Double)
    Me._id = id
    Me._txt = txt
    Me._num = num
  End Sub
  Public Property ID() As Integer
       Get
          Return _id
       End Get
       Set(ByVal Value As Integer)
          _id = Value
       End Set
   End Property
   Public Property Txt() As String
       Get
          Return _txt
       End Get
       Set(ByVal Value As String)
          _txt = Value
       End Set
    End Property
   Public Property Num() As Integer
       Get
          Return _num
       End Get
       Set(ByVal Value As Integer)
          _num = Value
       End Set
    End Property
 End Class

'Populate the chart before printing Private Sub chart1_BeforePrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs)
     ' Create a list.
     Dim listDataSource As New ArrayList()
    ' Populate the list with records.
     listDataSource.Add(New Record(1, "Android", 29))
     listDataSource.Add(New Record(2, "Galaxy", 32))
     listDataSource.Add(New Record(3, "Lumia", 51))
     listDataSource.Add(New Record(4, "iPhone", 84))
    ' Remove the default series if any
     for i as integer = 0 to chart1.series.count-1
       dim serie as series = chart1.series(i)
       chart1.Series.remove(serie)
     next i
     ' Bind the chart to the list.
     chart1.DataSource = listDataSource
    ' Create a series, and add it to the chart.
     Dim series1 As New Series("My Series", ViewType.Bar)
     Chart1.Series.Add(series1)
    ' Adjust the series data members.
     series1.ArgumentDataMember = "txt"
     series1.ValueDataMembers.AddRange(New String() { "num" })
    ' Access the view-type-specific options of the series.
     CType(series1.View, BarSeriesView).ColorEach = True 
     series1.LegendPointOptions.Pattern = "{A}"
End Sub

Now preview the report and you will  get the following:

Sample Report available HERE to download.

Microsoft Excel Alternative

April 21, 2012 Leave a comment

If you add a table control to your report, you can have the table work similar to a spreadsheet like Excel. You can add rows and columns. Each cell can be formatted independently. You can put text and numbers in each cell. You can link a cell to a field in a data source.

The harder part is dealing with formulas. But there is a simple method for that. Each cell can be named and you can change the default name to anything you want. So you can give them meaningful names. Then the formulas are placed in the scripts on the report before print event. The formulas would be written in vb.net, C#, or J-script. And with the programming constructs like looping, conditional if then else, case statements, etc., plus all the functions available.  You can have the calculations even more powerful than your typical spreadsheet software.

To view the results of the calculations, just run or preview the report.

Here is a simple example. Assume there is a table with two cells named A and B and they contain numeric data. If you want the sum of A and B put in a third cell named C, the script would look like this…

Private Sub Detail_BeforePrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs)
C.text = csng(A.text) + csng(B.text)
End Sub

The cells contain a text property and it needs to be converted to numeric in code so you can do calculations. The csng function does this and converts the text to a single precision value. You need to refer to each cell with the “.text” property.