Previous | Contents | Index |
KILL file_spec |
Example 14-26 KILL Statement - Deleting a File |
---|
! DANGER -- Executing this program will DELETE a file input 'What file do you want to delete': file$ kill file$ end What file do you want to delete? |
KILL is used to permanently delete a file from within a Sheerpower program.
KILL searches for and deletes the file specified in file_spec, a string expression. If the file name has a version number appended, such as:
my_program.spsrc-1 |
The full file name and extension must be included, along with the version number. If the version number is not included, KILL will delete the most recent version of the file.
If the file cannot be deleted, Sheerpower will return an error. To suppress the error, the option "CONDITIONAL" can be used with the KILL statement:
kill conditional: 'file_to_kill.xxx' |
Sheerpower will kill/delete the file if possible, but will not generate any errors if it cannot.
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 Console window. To do this, you need to open a separate TEXT WINDOW using textwindow://.
When the channel to the text window is closed, the actual text window 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.
The MEDIA statement in Sheerpower supports opening .WAV files. The MEDIA statement also has an optional LOOP parameter:
media loop: string_expr$ // play this over and over again |
Example 14-31 Playing WAV Files in a Loop |
---|
media loop: 'c:\sheerpower\samples\yes.wav' |
The LOOP option causes the WAV file to continuously play over and over again as the program continues execution. This can be used to provide "background music" to an application.
To stop playing looped media:
Example 14-32 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 table statements. One of the major features of Sheerpower is its ability to perform database operations as part of the language. The data table statements allow you to manipulate data table in your own programs.
List of Data Table Statements:
OPEN TABLE
CLOSE TABLE
EXTRACT TABLE
REEXTRACT TABLE
CANCEL EXTRACT
ADD TABLE
DELETE TABLE
INCLUDE
EXCLUDE
SORT
FOR EACH
ASK TABLE
SET TABLE
LOCK TABLE
UNLOCK TABLE
UNLOCK TABLE: COMMIT
UNLOCK ALL: COMMIT
In all data table 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 tables. (Chapter 16, Database Setup describes how tables are created.) A table file contains the following information:
In Sheerpower, you address the table file and not the dataset directly.
A Sheerpower table is made up of records and fields. A table looks something like this:
Example 15-1 Data Table 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 table 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 table and the desired field. The field name is enclosed in parentheses.
table_name(field_name) |
table_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 Table |
---|
open table cl: name 'sheerpower:samples\client' extract table cl: key id = '80522' print cl(last), cl(first) // print last and first // fields from the CL table end extract close table cl end Errant Earl |
Previous | Next | Contents | Index |