SheerPower® 4GL
A Guide to the SheerPower Language


Previous Contents Index

14.7.1 SET #chnl_num: Options

An option must be included with the SET #chnl_num statement. The set options currently available are described below:

ZONEWIDTH num_expr

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.

MARGIN int_expr

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 

CURRENT str_expr

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

FORMAT:


        KILL str_expr 

EXAMPLE:

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? 

PURPOSE:

KILL is used to delete a file from within your program.

DESCRIPTION:

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

FORMAT:


  open #u: name "textwindow://title?width=nn&height=mm&max=qqqq" 

EXAMPLE:

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

PURPOSE:

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.

DESCRIPTION:

Below is a table of textwindow attributes.

Table 14-1 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

14.10 Printing Output Using the PASS Statement

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

Printing HTML Output

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

14.11 Playing Media Files using the MEDIA Statement

FORMAT:


  media str_var 

EXAMPLE:

Example 14-30 Playing MEDIA Files

  // Play some sounds 
  for i = 1 to 3 
    media '@yes.wav' 
  next i 
  media '@sorry.wav' 
  end 

PURPOSE:

The MEDIA statement allows you to open media files with SheerPower.

DESCRIPTION:

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 

Note

See Section 6.7, File and Structure Access Functions for more on working with files in SheerPower.


Previous Next Contents Index