| Previous | Contents | Index |
SET SCROLL statement sets up a scrolling region from line num_expr1 to line num_expr2.
RANDOMIZE
|
| Example 11-17 Randomize statement |
|---|
randomize
x = rnd
print x
end
run
.244013674718
run
.524856061388
|
RANDOMIZE gives the RND function a new starting point. This ensures a different random number sequence each time a program executes.
SheerPower uses a list of random numbers when the RND function is used. If no RANDOMIZE statement is used, SheerPower starts at the same place in this list each time the program executes. This means the same series of random numbers is returned each time the program executes.
RANDOMIZE tells SheerPower to pick a random starting point in the list. 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.)
ASK SEED num_var
SET SEED num_expr
|
| Example 11-18 ASK/SET SEED statement |
|---|
randomize
ask seed seed_num
for i = 1 to 3
print rnd(1000)
next i
print 'Reset the random sequence'
set seed seed_num
for i = 1 to 3
print rnd(1000)
next i
end
608
88
506
Reset the random sequence
608
88
506
|
ASK SEED sets or resets the pseudo-random number sequence.
ASK SEED returns the current starting point of a pseudo-random sequence and stores the number in num_var.
SET SEED sets the starting point of a pseudo-random sequence with the number in num_expr.
There are a number of ASK SYSTEM and SET SYSTEM statements. These are described in the following sections. The ASK/SET statements ask about and set various system operation features.
ASK SYSTEM: COMMENT str_var
|
| Example 11-19 ASK SYSTEM: COMMENT statement |
|---|
set system: comment 'Invoice Entry' ask system: comment c$ print c$ end Invoice Entry |
The ASK SYSTEM: COMMENT statement asks for the SheerPower operating system comment for the process.
SET SYSTEM: COMMENT str_expr
|
| Example 11-20 SET SYSTEM: COMMENT statement |
|---|
set system: comment 'Invoice Entry' ask system: comment c$ print c$ end Invoice Entry |
ASK SYSTEM: DIRECTORY str_var
|
| Example 11-21 ASK SYSTEM: DIRECTORY statement |
|---|
ask system: directory z$ print 'Current directory is: '; z$ end Current directory is: c:/sheerpower |
ASK SYSTEM: DIRECTORY asks the operating system for the current default device and directory.
SET SYSTEM: DIRECTORY str_var
|
The following example assumes that you have a folder named "examples" inside of your SheerPower folder [c:\SheerPower\examples]. |
| Example 11-22 ASK SYSTEM: DIRECTORY statement |
|---|
ask system: directory z0$ print 'Current directory '; z0$ set system: directory 'c:\sheerpower\examples' ask system: directory z1$ print 'Directory set to '; z1$ delay 2 set system: directory z0$ print 'Directory set back to '; z0$ end Current directory c:\sheerpower Directory set to c:\sheerpower\examples Directory set back to c:\sheerpower |
SET SYSTEM: DIRECTORY sets the default device and directory.
ASK SYSTEM, LOGICAL str_expr: VALUE str_var
|
| Example 11-23 ASK SYSTEM, LOGICAL: VALUE statement |
|---|
ask system, logical "SheerPower": value scr$ print '"SheerPower" points to: '; scr$ end "SheerPower" points to: c:\SHEERPOWER\ |
ASK SYSTEM, LOGICAL asks the operating system to translate the logical name in str_expr and place the result into the variable specified by str_var.
SET SYSTEM, LOGICAL str_expr1: VALUE str_expr2
|
| Example 11-24 SET SYSTEM, LOGICAL: VALUE statement |
|---|
set system, logical 'SheerPower': value 'c:\sheerpower\examples\tester' ask system, logical 'SheerPower': value z$ print 'Logical set to '; z$ end Logical set to c:\sheerpower\examples\tester |
SET SYSTEM, LOGICAL: VALUE statement sets the operating system logical name in str_expr1 to the value in str_expr2.
You can also set logical values by editing the SP4GL.INI file, creating a [logicals] section, then defining the logical. For example:
| Example 11-25 Set Logicals in SP4GL.INI |
|---|
[logicals] mylogical=c:\somewhere |
ASK SYSTEM: MODE str_var
|
| Example 11-26 ASK SYSTEM: MODE statement |
|---|
ask system: mode process_mode$ print 'Process Mode: '; process_mode$ end Process mode: BATCH |
ASK SYSTEM: MODE statement returns the mode of the process which is one of the following:
INTERACTIVE
BATCH
NETWORK
OTHER
ASK SYSTEM: PARAMETER str_var
|
ASK SYSTEM: PARAMETER works only in Windows 2000 and Windows NT.
|
| Example 11-27 ASK SYSTEM: PARAMETER statement |
|---|
ask system: parameter param$
print 'Parameter was: '; param$
delay
end
c:\sheerpower> test.spsrc hello <---- type in 'test.spsrc hello' at the Command (DOS)
prompt to run this program.
Parameter was: hello <---- this will appear in the console window
|
| Previous | Next | Contents | Index |