Shiny Language Reference

Language Reference > Basic Types


Advanced ("Extended") Language Types

file

font

image

pen

web

 

The advanced variable types

Shiny uses 5 advanced types to represent objects external to the plugin. Each type can be considered a "handle" to a resource. Implicit type conversion is not available for the advanced types as there is no logic in converting between them. A comprehensive tutorial on these types begins here.

The Shiny compiler acts in the same way as the Visual Basic "Option Explicit" statement, in other words all variables must be declared before they are used. Variables may be declared in one of two ways:

  1. Using the Visual Basic-like DECLARE statement.

  2. Using the C-like declaration syntax

 

An example VB-like declaration. This statement declares a variable called "MyLogFile" as a handle to a file.

declare MyLogFile file;

 

The same declaration using C-like syntax:

file MyLogFile;

 

The compiler produces identical code for both of these statements. In their default form as shown there is no benefit in using one instead of the other, simply pick the style you are comfortable with.

Unlike basic variable types, it is not possible to declare and assign a variable in one step. This is because creation of these variable handles is a complex process which much be initiated by a specific statement (for example, CREATEPEN for pens)

 

Arrays and Globals

Advanced type variables behave identically to basic types for arrays and global/local scope. Refer to the basic types reference. Note that using arrays for advanced types may get confusing for anyone reviewing your code, even though it is legal syntax.

 

 

Type descriptions

Variable Type Contains
file A handle to a local file. See FOPEN.
 
font A font typeface, size, style and colour to use for displaying text. See CREATEFONT.
 
image A GIF, JPG, BMP, EMF or WMF image. See CREATEIMAGE.
 
pen A pen width, style and colour to use for drawing lines. See CREATEPEN.
 
web A handle to a URL accessible via HTTP. See WOPEN.
 

Type conversions

No type conversion is possible. There is no logic or value in converting (for example) a font to a web handle.