FREE PowerBuilder Training

Introduction to PowerBuilder

HomePrevious Lesson: Questions & Answers
Next Lesson: PowerScript - Database Operations

Exercises

Please complete the following exercises. We advise you not to download the solution till you complete the exercises. Please note that the following exercises are not part of the 'Product Management System'  project, these are designed to give you experience in events & PowerScript only.

#

Problem Description

1.

Paint the window shown below. The same window is used in exercises 1 to 4. The train picture on the window is a picture control, below it is a SingleLineEdit control and a ListBox and a StaticText control. The rest are CommandButtons.

In this exercise, write the script to 'Add to ListBox' CommandButton for adding the text provided in SingleLine Edit control to the ListBox.

Tip: AddItem()

Solution: - w_script_practice2.srw

2. Write script to display the ListBox's selected item's text on the StaticText control.

Tip: SelectionChanged Event

Solution: - See solution of exercise one.

3. Write script to the 'Hide All' CommandButton to hide all controls in the window except self and change the text to 'Show All' and vice-versa.

Tip: Clicked event, Hide(), Show() and Visible Property.

Solution: - See solution of exercise one.

4. Write script(s) to move the picture control ( train ) along with the mouse pointer in the window when clicked. Stop moving the picture control when clicked on the picture control again.

Tip: You need to declare an instance variable by selecting 'Declare/Instance Variables...' from the menu. We know that this topic is not yet covered, but, knowing one point is good enough for this exercise. The instance variable is available throughout the window. You need to write script to Clicked event of the picture control and mousemove event of the window. You may want to use PointerX() and PointerY() functions to get the mouse pointer's x and y co-ordinates. Good luck!

Solution: - See solution of exercise one.

HomePrevious Lesson: Questions & Answers
Next Lesson: PowerScript - Database Operations
 
Copyright © 1996 - 2013 Prasad Bodepudi. All Rights Reserved.