Displaying Text

 

Next Topic

 

 

The WIL Tutorial

§         Topic by Topic

§         The Tutorial Course

§         The Complete WIL Tutorial

 

Getting started

Using WIL

Reference

Notes

 

 

 

image\gflag3_shg.gif
Tutor Example continued..
.

1. Exit Solitaire.

2. Activate or open your editor.

3. Load tutor.wbt.

4. Add the new lines.

5. Save the file.

6. Run the wbt by double-clicking on the filename.

 

image\golftee_shg.gifNext…

 

 

 

 

Now, let's modify our original WIL program as follows:

; solitare.program

Display(5, "Good Luck!","Remember… it's only a game.")

Run("C:\Program Files\Microsoft Games\Solitaire\Solitaire.exe", "")

 

And run it. Notice the little dialog box which pops up on the screen with words of encouragement:

image\tutbut1_shg.gif

That's done by the Display function in the second line above. Here's the reference for Display:

Syntax:

Display (seconds, title, text)

Parameters:

(i) seconds seconds to display the message (1-3600).

(s) title Title of the window to be displayed.

(s) text Text of the window to be displayed.

 

The Display function has three parameters. The first parameter is the number of seconds which the display box will remain on the screen (you can make the box disappear before then by pressing any key or mouse button). This is a numeric constant, and - unlike string constants - it does not need to be enclosed in quotes (although it can be, if you wish, as WIL will automatically try to convert string variables to numeric variables when necessary, and vice versa). In our example above, we are displaying the box for 5 seconds. The second parameter is the title of the message box, and the third parameter is the actual text displayed in the box.

Note:  In our shorthand method for indicating syntax the (s) in front of a parameter indicates that it is a string. An (i) indicates that it is an integer, (f) indicates a floating point number parameter, (a) indicates an array, (r) indicates a COM/.NET object reference , (t) indicates special type information described in the function’s text and (v) indicates a variant.

 

 

 

image\gflag4_shg.gif
Tutor Example continued...

 

Now, exit Solitaire (if you haven't done so already), and edit the WIL program by placing a semi-colon at the beginning of the line with the Run function. This is a handy way to disable, or "comment out," lines in your WIL programs when you want to modify and test only certain segments. Your WIL program should look like this:

; solitare.program
Display(5,"Good Luck","Remember… it's only a game")
; Run("C:\Program Files\Microsoft Games\Solitaire\Solitaire.exe", "")

 

 

image\golftee_shg.gif

 Next…

1. Exit Solitaire.

2. Edit tutor.wbt -Comment out the Run statement.

3. Save the file.

4. Run the wbt by double-clicking on the filename.

 

Feel free to experiment with modifying the parameters in the Display function. Try adjusting the value of the first parameter. If you look up Display in the WIL reference section, you will see that the acceptable values for this parameter are 1 3600. If you use a value outside this range, WIL will adjust it to "make it fit"; that is, it will treat numbers less than 1 as if they were 1, and numbers greater than 3600 as 3600.

Also, try using a non-integer value, such as 2.9, and see what happens (it will be converted to an integer). Play around with the text in the two string parameters; try making one, or both, null strings ("").