Silverfrost Logo About Us | Contact Us

Step 1

Begin by opening a "Command Prompt" Window (DOS box).

Now use your text editor to list factor1.for.

Here is the text of factor1.for. Line numbers have been added so that each line can be referenced in the explanation below.

3      PROGRAM factor1
5      INCLUDE <windows.ins>
6      INTEGER ans
7      ans=winio@('%ca[Number Factoriser]')
8      END

You can compile and link this program with a command line of the form:

       FTN95 FACTOR1 /LINK

This produces a Windows executable factor1.exe that can be run by typing


from the DOS box command line.

Alternatively you can run the executable from the Program Manager.

factor1.for simply opens a format window with a caption like this:

The window may differ slightly in its appearance from one version of Windows to another.

The quickest way to terminate the application is to press Alt-F4.

Now that you have seen the application running, have a look at the code. Before looking at line 7, which is the key line in this program, let's get some preliminaries out of the way first.

Line 1 provides information for the linker that is called when you use /LINK on the compiler command line. It causes the linker to produce a Windows executable. For a Win32 application, the zero values on this line are redundant. (Some later compilers allow you to omit these values.)

cwp_ico.rc is the name of what is called a resource script that can be found in the same directory as factor1.for. This particular resource script provides information about an icon that is embedded in the application. In the program this "Window" icon is not used in the application itself but is simply available as a icon that identifies the application when it is installed in the Program Manager or its equivalent.

WINAPP must be the first compiler directive in the file and must appear before the main program.

Line 4 is recommended as a standard line for all programs and routines that use the file windows.ins. This line is a compiler directive that ensures that all variables are given an explicit type. It is included because the names of many of the Windows parameters are very long and consequently they are easy to misspell. Without this directive, such bugs are very hard to find. The file factor.for is too short for this to matter, but never-the-less we adopt the practice here as a matter of routine.

Line 5 is a call to include the file windows.ins. The diamond brackets indicate that the file is located within the Silverfrost compiler directory. This file contains type declarations for many of the ClearWin+ and Windows API routines and parameters. The only information of relevance to this particular main program is that winio@ returns an INTEGER result (in this guide, all integers are 32 bits long unless otherwise stated). Note that, if you are only using winio@ from the ClearWin+ library, then you will reduce the compilation time by replacing the INCLUDE line by

INTEGER winio@

This brings us to line 7 and the heart of this and most ClearWin+ applications. winio@ is a ClearWin+ function that allows you to create a format window that displays all manner of graphical user interface (GUI) objects such as menus, buttons, pictures, formatted text, list boxes and icons. It also allows you to specify what action is to be taken in response to the options that you present to the user. This means that this one function can be used to avoid the complexities of writing a GUI application based on calls to the standard API library combined with a detailed resource script and complex call-back functions.

The first (and in this case only) argument of winio@ is called a format string. In the present case the format string starts with %ca and this is an example of what is called a format code. The format code %ca stands for 'caption' and it supplies a title for the format window. The title itself appears in square brackets after the format code.

There are many format codes available and all of them are represented by a % sign and a two letter format code. Additional information is often supplied (as here) by adding text enclosed in square brackets. This text is called a standard character string. We shall see later that sometimes extra information is placed between the % sign and the two letters. In other cases the format code is allowed to collect information from additional arguments that are presented after the initial format string argument of winio@.

This brings us to the end of step 1 in our development process.



Copyright © 1999-2017 Silverfrost Limited