Chapter 3 DynaScript Predefined Objects


system object

Object

Provides functionality for interacting with the server's operating system environment.

Syntax

To use a system property:

system.propertyName

To use a system method:

system.MethodName( parameter ) 

Description

The system object is provided for you.

Example

This example modifies the system path.

<--SCRIPT
  // Adds e:\src to the Environment System Path
  path = system.GetEnv( "PATH" );
  path = path + "e:\src;";
  system.SetEnv( "PATH", path, true );
-->

See also

"errorNumber property"

"errorString property"

errorNumber property

Syntax

system.errorNumber 

Attributes

This property is read-only.

Description

A number [integer] representing the error code of the last system method call.

Example

This example displays an error code:

<!--SCRIPT
  document.WriteLn( system.errorNumber );
-->

See also

"errorString property"

errorString property

Syntax

system.errorString 

Attributes

This property is read-only.

Description

A string containing an error message for the error code of the last system method call. This is a read-only property.

Example

This example displays an error message:

<!--SCRIPT
  document.WriteLn( system.errorString );
-->

See also

"errorNumber property"

Exec method

Syntax

system.Exec(cmd)

Description

Executes a command outside the Dynamo Script Interpreter.

Return

Boolean. Returns true or false indicating whether or not the call succeeded:

Example

This example launches the Windows Notepad utility.

<--SCRIPT
  // Launches notepad
  system.Exec( "notepad.exe" );
-->

GetCWD method

Syntax

system.GetCWD( )

Description

Returns the current working directory.

Return

String

Example

To return the current directory:

<!--SCRIPT
  // Prints the current working directory
  document.WriteLn( system.GetCWD() );
-->

GetEnv method

Syntax

system.GetEnv(env)

Description

Searches the environment for an environment entry matching env , and returns its value.

Return

String or null if no matching entry found

Example

This example retrieves the environment's PATH entry:

<!--SCRIPT
  path = system.GetEnv( "PATH" );
-->

SetEnv method

Syntax

system.SetEnv(env,value,overwrite)

Description

Searches the environment for an entry matching env . If there is no such entry, an entry is created and set to value ; otherwise, if overwrite is true the entry is set to value .

Example

This example modifies the system path.

<!--SCRIPT
  // Adds e:\src to the Environment System Path
  path = system.GetEnv( "PATH" );
  path = path + "e:\src;";
  system.SetEnv( "PATH", path, true );
-->

 


Copyright © 2001 Sybase, Inc. All rights reserved.