Posts Tagged ‘Scripts’

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.


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.

Report Scripts

April 15, 2012 Leave a comment

When designing a report you can use scripts to handle special requirments. Scripts are program commands, placed within the event handlers of the report, band, and control elements. When the corresponding event occurs, the script code runs.  Events occur when the report is previewed, printed, or exported.

Although when in the Report Designer, virtually any task can be accomplished without scripting (Conditionally Change a Control’s Appearance, Conditionally Change a Label’s Text and Conditionally Hide Bands), scripting is made available to extend the standard functionality even more.  The Scripts Tab allows you to manage your report’s scripts. It provides centralized access to all the scripts being written for a report or any of its elements (bands and controls).  The built-in scripts validation capability is provided in this tab. After clicking Validate, the result is displayed in the Scripts Errors Panel.  Scripts are saved to a file along with the report’s layout.

The report scripts may be written in one of the following languages that the .NET framework supports – C#, Visual Basic and J#. Since J# is not installed with the framework installation, by default, make sure it is present before writing code in it. The scripting language is specified via the Script Language property of the Report object.

Script execution is performed in the following way: The report engine generates a temporary class in memory. The names of the variables are defined by the Name properties of the controls and objects they represent. When the script is preprocessed, its namespace directives are cut from the script code and added to the namespace, where the temporary class is defined. After preprocessing, all scripts are placed in the code of the temporary class. Then, the resulting class is compiled in memory, and its methods are called when events occur. Scripting offers many advantages: you can declare classes (they will become inner classes), variables, methods, etc. A variable declared in one script is accessible in another script, because it is, in fact, a variable of the temporary class.

The Script References property of the Report object specifies the full paths (including the file names) to the assemblies that are referenced in the scripts used in a report. These paths should be specified for all the assemblies that are included in scripts via the using (C#), Imports (Visual Basic) or import (J#) directives. Usually, you don’t need include any assembles, because most standard assemblies that you may require in scripts are already referenced by the program.