Sheerpower®
A Guide to the Sheerpower Language


Previous Contents Index

EXAMPLE:

Example 11-8 SET EXIT OFF Statement

  line input 'Name', length 30: reply$ 
  print _exit
  set exit off
  print _exit
  end
 
 
Name? EXIT__________________________ 
1 
0 

DESCRIPTION:

SET EXIT OFF sets the internal variable _EXIT to FALSE (0).

11.6 SET HELP ON | OFF

11.6.1 SET HELP ON

FORMAT:


        SET HELP ON 

EXAMPLE:

Example 11-9 SET HELP ON Statement

  line input 'Name', length 30: reply$ 
  print _help
  set help on
  print _help
  end
 
 
Name? MIKE__________________________ 
0 
1 

DESCRIPTION:

SET HELP ON sets the internal variable _HELP to TRUE (1).

11.6.2 SET HELP OFF

FORMAT:


        SET HELP OFF 

EXAMPLE:

Example 11-10 SET HELP OFF Statement

  line input 'Name', length 30: reply$ 
  print _help
  set help off
  print _help
  end
 
 
Name? HELP__________________________ 
1 
0 

DESCRIPTION:

SET HELP OFF sets the internal variable _HELP to FALSE (0).

11.7 SET ICON

FORMAT:


        SET ICON 'str_exp' 

EXAMPLE:

Example 11-11 SET ICON Statement

// dynamically change the taskbar icon 
 
  set icon "c:\sheerpower\samples\smiley.ico" 
  print "Check out the taskbar icon... it's a smiley!" 
  delay
  set icon "c:\sheerpower\samples\frowny.ico" 
  print "and now... it's changed to a frown!" 
  end

DESCRIPTION:

SET ICON changes the icon displayed on the taskbar for each running Sheerpower application. A unique icon can be specified for every Sheerpower application. The icon can be dynamically changed during program execution.

11.8 ASK KEYSTROKES

FORMAT:


         ASK KEYSTROKES num_var 

EXAMPLE:

Example 11-12 ASK KEYSTROKES Statement

  input 'Please enter your name': name$ 
  print 'Hello '; name$ 
  ask keystrokes strokes 
  print 'Keystrokes:'; strokes 
  end
 
 
Please enter your name? Maryanne 
Hello Maryanne 
Keystrokes: 8 

DESCRIPTION:

ASK KEYSTROKES asks for the number of user-entered keystrokes.

11.9 ASK | SET MARGIN

11.9.1 ASK MARGIN

FORMAT:


        ASK MARGIN num_var 

DESCRIPTION:

ASK MARGIN finds the right margin of the device specified and assigns its value to the numeric variable num_var.

11.9.2 SET MARGIN

FORMAT:


        SET MARGIN num_expr 

EXAMPLE:

Example 11-13 SET MARGIN Statement

  print repeat$('.' ,200) 
  print 
  ask margin old_marg 
  input 'What do you want the margin set to': new_marg 
  set margin new_marg 
  print repeat$('.' ,200) 
  set margin old_marg 
  end
 
 
.................................................. 
.................................................. 
.................................................. 
.................................................. 
 
What do you want the margin set to? 20 
.................... 
.................... 
.................... 
.................... 

DESCRIPTON:

SET MARGIN sets the right margin on the device specified to the number indicated. num_expr specifies the column to set the margin to. The margin must be greater than zonewidth.

11.10 ASK PAGESIZE

FORMAT:


        ASK PAGESIZE num_var 

EXAMPLE:

Example 11-14 ASK PAGESIZE Statement

  ask pagesize no_lines 
  print 'There are'; no_lines; 'lines or rows on this screen' 
  end
 
 
There are 24 lines or rows on this screen 

DESCRIPTION:

ASK PAGESIZE returns the number of rows or lines of screen output.

11.11 SET PROGRAM TIMEOUT

FORMAT:


        SET PROGRAM TIMEOUT n 

EXAMPLE:

Example 11-15 SET PROGRAM TIMEOUT Statement

  set program timeout 5 
  for x = 1 to 100 
   print x 
   delay 1 // wait one second 
  next x 
  end
 
// When you run this program you will see that it never reaches 100 seconds. 
// Instead the it times out at 5 seconds. 

PURPOSE:

This allows you to control if the program does not end within the specified number of seconds, then end it anyway. This feature is very useful to limit the time a script from a webpage can run. For more on writing scripts in Sheerpower see Chapter 19, Sheerpower Web Scripting.

DESCRIPTION:

SET PROGRAM TIMEOUT is useful if you are running Sheerpower scripts and want to control the maximum time that a script can run. A typical value might be 1 (one second.)

11.12 ASK RESPONSES

FORMAT:


        ASK RESPONSES num_var 

EXAMPLE:

Example 11-16 ASK RESPONSES Statement

  input 'Please enter your name': name$ 
  input 'What day is this': what_day$ 
  print 'Hello '; name$ 
  print 'Have a good '; what_day$ 
  ask responses answers 
  print
  print 'Responses:'; answers 
  end
 
 
Please enter your name? Ginger 
What day is this? Wednesday 
Hello Ginger 
Have a good Wednesday 
 
Responses: 2 

DESCRIPTION:

ASK RESPONSES asks for the number of completed input responses.

11.13 SET SCROLL

FORMAT:


        SET SCROLL num_expr1, num_expr2 

EXAMPLE:

Example 11-17 SET SCROLL Statement

  print at 21, 1: 'This text will not scroll.' 
  set scroll 5, 20 
  print at 20, 1:;  
  delay 1 
  print 'This'  
  delay 1 
  print 'text'  
  delay 1 
  print 'will'  
  delay 1 
  print 'scroll.'  
  delay 1 
  set scroll  1,24 
  end
 
 
 
This 
text 
will 
scroll 
 
This text will not scroll. 

DESCRIPTION:

The SET SCROLL statement sets up a scrolling region from line num_expr1 to line num_expr2.

11.13.1 RANDOMIZE

FORMAT:


        RANDOMIZE 

EXAMPLE:

Example 11-18 Randomize Statement

  randomize
  x = rnd 
  print x 
  end
 
run
.244013674718 
 
        
run
.524856061388 

PURPOSE:

RANDOMIZE gives the RND function a new starting point. This ensures a different random number sequence each time a program executes.

DESCRIPTION:

Sheerpower uses a pseudo-random number sequence to generate random numbers. It uses a SEED value to start the sequence. The SEED changes each time that the RND function is used. Sheerpower used the system clock to set the initial SEED value.

RANDOMIZE tells Sheerpower to pick a random SEED value. This ensures that a different series of random numbers is returned each time the program executes. (See Section 6.1.12, RND for information on the RND function. See Section 11.14, ASK | SET SEED for the ASK/SET SEED statement.)

On using RANDOMIZE within a program

RANDOMIZE should only be done ONCE per the run of the program. It just uses the system clock to start the random number seed. RANDOMIZE should not be used inside of a LOOP.


Previous Next Contents Index