| Previous | Contents | Index |
ASK #chnl_num: NAME asks the SheerPower operating system for the file specification of the file open on channel #chnl_num and stores the value into str_var.
| Example 14-22 ASK#chnl_num: NAME |
|---|
out_ch = 12
open #out_ch: name 'sheerpower:minutes.txt', &
access output
ask #out_ch: name x$
print x$
close #out_ch
end
c:SHEERPOWER\minutes.txt
|
SET # chnl_num: [ ZONEWIDTH num_expr ] [, MARGIN int_expr]
[, CURRENT str_expr]
|
| Example 14-23 SET#chnl_num statement |
|---|
open #3: name 'storage.ars', access output ask #3: zonewidth x print 'The current print zone width is'; x set #3: zonewidth 35 ask #3: zonewidth x print 'The new print zone width is'; x close #3 end The current print zone width is 20 The new print zone width is 35 |
SET #chnl_num sets various device characteristics. chnl_number is a channel number. If no channel number is specified, SheerPower sets the default device (the terminal). If a channel number is specified, SheerPower sets the device associated with that channel number.
When a device characteristic is SET, it remains set until the device is closed. Therefore, if the terminal is SET, it will remain SET until you exit from the SheerPower environment or the SET statement is used again.
An option must be included with the SET #chnl_num statement. The set options currently available are described below:
SET #chnl_num: ZONEWIDTH sets the print zone width of the device specified to the number designated. num_expr indicates the width to set the device's print zones. See above example.
SET #chnl_num: MARGIN sets the right margin on the device specified to the number indicated. int_expr specifies the column to set the margin to. The margin must be greater than the zone width.
| Example 14-24 SET#chnl_num: MARGIN |
|---|
open #3: name 'storage.ars', access output
set #3: margin 45
print #3: repeat$('1234567',10)
close #3
open #3: name 'storage.ars', access input
do
line input #3, eof endfile?: item$
if endfile? then exit do
print item$
loop
close #3
end
123456712345671234567123456712345671234567123
4567123456712345671234567
|
SET #chnl_num: CURRENT sets the current record to that specified by str_expr. The str_expr contains the information for the record you want to make current.
| Example 14-25 SET#chnl_num: CURRENT |
|---|
open #1: name 'temp.txt', access output
for z = 1 to 20
print #1: 'This is line number '; z
next z
close #1
open #1: name 'temp.txt'
for i = 1 to 5
line input #1: a$
next i
ask #1: current c$
print '5th item was: '; a$
for i = 1 to 5
line input #1: a$
next i
print '10th item was: '; a$
set #1: current c$
line input #1: a$
print 'Back to 5th item again: '; a$
close #1
end
5th item was: This is line number 5
10th item was: This is line number 10
Back to 5th item again: This is line number 5
|
14.8 Deleting Files
14.8.1 KILL
KILL str_expr
|
| 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 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
|
| Previous | Next | Contents | Index |