|
Corel Click &
Create
Tip 6 - Working with paths, INI files, Edit
boxes, and a Picture object
This is a basic example which demonstrates paths, INI
files, Edit boxes, and a Picture object. This example will allow developers to work with paths
that aren't relative to their installed application. In this example, an INI file is used to retrieve a
path to some graphic files. The user is expected to enter a valid name of a PCX or BMP file in
the user entry text box. When the user presses the enter key, the application will append the file
name that the user typed to the path from the INI file and display the file in the Picture
box.
To try out this procedure, copy a picture file (*.PCX) to
the directory C:\CNC\APPS.
In the Frame Editor, add three objects to the Click &
Create playfield: a picture object with no file specified (don't enter a file name in the Picture box,
just click OK); an INI object with no file specified (don't enter a file name in the INI file to use
box, just click OK); and an Edit box.
In the Event Editor set events to specify an INI file and
set a path variable to C:\CNC\APPS\:
- In the Event Editor, click the New condition box and
double click the Storyboard controls icon.
- Choose Start of Frame from the pop-up menu.
- Find the empty grid box that corresponds to the new
condition and is under the INI object icon. Click this grid box with the right mouse button.
- Choose Set current file from the pop-up menu.
- Type the following file name between the quotation
marks in the expression box "C:\CNC\APPS\TEST.INI".
- Click OK. An action marker will appear in the grid box
to show that the action "Set current file to "C:\CNC\APPS\TEST.INI"has been
set.
- Click the same grid box again with the right mouse
button.
- Choose Set current group from the pop-up menu.
- Type the following file name between the quotation
marks in the expression box "Path".
- Click OK. An action marker will appear in the grid box
to show that the action "Set current group to "Path"has been set.
- Click the same grid box again with the right mouse
button.
- Choose Set current item from the pop-up menu.
- Type the following file name between the quotation
marks in the expression box "Picture Path".
- Click OK. An action marker will appear in the grid box
to show that the action "Set current item to "Picture Path"has been set.
- Click the same grid box again with the right mouse
button.
- Choose Set string from the pop-up menu.
- Type the following file name between the quotation
marks in the expression box "C:\CNC\APPS\".
- Click OK. An action marker will appear in the grid box
to show that the action "Set item string to "C:\CNC\APPS\"has been set.
Now, we have to collect the information from the Edit
box and pass it to the Picture object to display the specified picture.
- In the Event Editor, click the New condition box and
double click the Mouse pointer and keyboard icon.
- Choose The keyboard, Upon pressing a key from the
pop-up menu.
- Press ENTER.
- Find the empty grid box that corresponds to the new
condition and is under the Picture object icon. Click this grid box with the right mouse button.
- Choose New picture from the pop-up menu.
- In the file list box, click the Expression button.
- Delete the quotation marks that appear in the expression
box.
- Click the Edit button and click Retrieve data from an
object.
- Double click the INI object and choose Get string from
the pop-up menu. This will retrieve the path the was specified in the INI file. Now we want the
path to be added to the file name that the user enters in the Edit box.
- Press the + key on your keyboard and click the Retrieve
data from an object button again.
- Double click the Edit object and choose Get text from
the pop-up menu.
- Click OK to accept the expression and return to the
Event Editor.
Now, run the completed application. Click the Edit box
and type the name of the graphic file that you copied to the C:\CNC\APPS\ directory at the
beginning of the lesson. Press Enter. The graphic will be displayed in the Picture
object.
![[Click here for
previous tip]](/deadend) ![[Click here
for next tip]](/deadend)
|
Click &
Create
|