| Previous | Contents | Index |
KILL is used to delete a file from within your program.
KILL searches for and deletes the file specified in str_expr, the string expression. The full file name must be included with extension. If no version number is included, KILL will delete the most recent version only.
14.9 Working with Text Windows
open #u: name "textwindow://title?width=nn&height=mm&max=qqqq" |
| Example 14-27 TEXTWINDOW:// |
|---|
open file text_ch: name 'textwindow://my text window?noclose&max=30', access output
for i=1 to 30
print #text_ch: i, sqr(i)
next i
delay
stop
|
Occasionally there is a need to output text to a window that is not the main SheerPower 4GL Debug Window. To do this, you need to open a separate TEXTWINDOW.
When the channel to the textwindow is closed, the actual textwindow is also closed.
Below is a table of textwindow attributes.
| Attribute | Description |
|---|---|
| title | the default title is "text window n" where "n" is the number of untitled windows created so far. |
| width | the width of the window in characters. The default is the width of the main console window. |
| height | the height of the window in characters. The default is the height of the main console window. |
| max | the maximum lines the user can scroll back. (the default is 10000) |
| noclose | no [x] close button in the text window |
The PASS statement can be used to print output from SheerPower.
| Example 14-28 Printing Output using PASS |
|---|
// Create your output text file:
outfile$ = 'myfile.txt'
open file out_ch: name outfile$, access output
for i=1 to 100
print #out_ch: i, sqr(i)
next i
close #out_ch
// Now print it out to the default printer
pass print: outfile$
end
|
You can output HTML code and then envoke the browser to display and print it using the PASS statement as illustrated in the following example:
| Example 14-29 Printing Output from an .HTML File |
|---|
// Create your output html file
outfile$ = 'myfile.html'
open file out_ch: name outfile$, access output
print #out_ch: '<html><body>'
print #out_ch: '<table border=3 bgcolor=lightblue>'
for i=1 to 100
print #out_ch: '<tr>'
print #out_ch: '<td>'; i; '<td>'; sqr(i)
print #out_ch: '</tr>'
next i
print #out_ch: '</table>'
print #out_ch: '</body></html>'
close #out_ch
// Now have the browser handle it
pass url: outfile$
end
|
media str_var |
| Example 14-30 Playing MEDIA Files |
|---|
// Play some sounds
for i = 1 to 3
media '@yes.wav'
next i
media '@sorry.wav'
end
|
The MEDIA statement allows you to open media files with SheerPower.
Currently the following media files are supported by the MEDIA statement in SheerPower:
The MEDIA statement also has as features/options:
media loop: string_expr$ // play this over and over again |
such as:
| Example 14-31 Playing Media Files in a Loop |
|---|
media loop: '@yes.wav' |
This will continue to play as the program continues execution. This can be used to provide "background music" to an application.
To stop playing looped media:
| Example 14-32 To Stop Playing Looped Media |
|---|
media '' // stop any background media that is playing |
See Section 6.7, File and Structure Access Functions for more on working with files in SheerPower. |
This chapter explains the SheerPower data structure statements. One of the major features of SheerPower is its ability to perform database operations as part of the language. The data structure statements allow you to manipulate data structures in your own programs.
List of Data Structure Statements:
OPEN STRUCTURE
CLOSE STRUCTURE
EXTRACT STRUCTURE
REEXTRACT STRUCTURE
CANCEL EXTRACT
ADD STRUCTURE
DELETE STRUCTURE
INCLUDE
EXCLUDE
SORT
FOR EACH
ASK STRUCTURE
SET STRUCTURE
LOCK STRUCTURE
UNLOCK STRUCTURE
In all data structure statements, the word TABLE can be used interchangeably with STRUCTURE. For example:
OPEN STRUCTURE is the same as OPEN TABLE |
SheerPower's data management system stores data file information in structures. (Chapter 16, Database Setup tells how structures are created.) A structure file contains the following information:
In SheerPower, you address the structure file and not the dataset directly.
A SheerPower structure is made up of records and fields. A structure looks something like this:
| Example 15-1 Data Structure DIAGRAM |
|---|
FIELDS
/ | \
/ | \
/ | \
/ | \
/ | \
R Client Last name First name
E Number
C +---------+---------------------------+-------------------+
O _____ |8|0|5|4|3|C|a|s|s| | | | | | | | | | |C|a|t|h|y| | | | | |
R _____ |8|0|5|4|2|B|r|o|c|k| | | | | | | | | |B|u|d| | | | | | | |
D | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
S
positions
|
In the above example, the records are the horizontal lines of information. In the CLIENT structure above, there is a record for each customer.
Each record consists of fields. For example, the customer records alone might contain a field for the customer's ID number, last name, first name, address, phone number, company name, etc. Each of these pieces of data is stored in its own field---the name field, address field, phone number field, etc. The fields appear as columns in the diagram above.
To reference a field, indicate the structure and the desired field. The field name is enclosed in parentheses.
struc_name(field_name)
|
struc_name is the name associated with the structure. field_name is the name of a field in the structure. SheerPower searches for the field specified in the current record and reads its contents.
| Example 15-2 SheerPower structure |
|---|
open structure cl: name 'sheerpower:samples\client'
extract structure cl: key id = '80522'
print cl(last), cl(first) // print last and first
// fields from the CL structure
end extract
close structure cl
end
Errant Earl
|
OPEN STRUCTURE struc_name: NAME 'struc_filename'
[, ACCESS INPUT | OUTIN] [, LOCK] [, DATAFILE filename]
[, OPTIMIZE OFF]
|
| Previous | Next | Contents | Index |