OrcaScript allows you to write batch scripts to process PowerBuilder applications and files without using the PowerBuilder development environment. You can use OrcaScript to get the latest version of a target from source control, build the target PBLs, and compile PowerBuilder executable files—all without operator intervention.

Using OrcaScript with source control

The targets you obtain from source control using OrcaScript could be placed on a network build computer that is shared by PowerBuilder developers. This is especially advantageous for large shops with fixed working hours: the builds could be done nightly by running an OrcaScript batch file, and an up-to-date version of the targets and libraries would be available at the start of the next work day.

Developers could then use OrcaScript or operating system commands to copy the shared files directly to their local computers. Although developers would still connect directly to source control from their local workspaces, refreshing the targets in the workspaces would be much faster since compilation times for complex targets would be greatly minimized.

Batch file order

If you include OrcaScript commands in a batch file, the file is read line by line. Each OrcaScript batch file must begin with a start session command and end with an end session command. You can save the batch file with any extension. You run the batch file by calling the OrcaScript executable on a command line and passing the batch file name as an argument:

`OrcaScr170 myOrcaBat.dat`

If you use relative directories in the OrcaScript batch file, create the batch file in the directory that is the required root directory at runtime. This must be in the same directory or in the path above a directory containing the files referenced by the batch file.

When you use relative directories, the OrcaScript batch file is portable for all users. However, users must make the directory where they copy the batch file the current directory (the one displayed in the DOS prompt) before invoking OrcaScr170.exe. The command to start the OrcaScript executable can also take the following parameters:

Parameter

Description

Example

/D

Sets variables that are valid in the batch file

OrcaScr170 /D myVar1=value1 /D myVar2=value2 myOrca.dat

/H or /?

Prints syntax help to screen

OrcaScr170 /H

### Caution

You should not run an OrcaScript batch file if PowerBuilder is currently running on the same computer. If the PowerBuilder development environment is not shut down while OrcaScript is running, your PowerBuilder libraries can become corrupted. For this reason, casual use of OrcaScript is not recommended.

Executing DOS commands and batch file

The OrcaScript commands can call DOS commands and arguments and the batch file. For example,

```start session
cmd "delete c:\test.txt"
end session```

Or

```start session
cmd "c:\test.bat"
end session```

The pbc170.exe tool can be used to automate the PowerBuilder application building process. See below to compare the scripts for building a project using the OrcaScript batch file and the pbc170.exe tool.

OrcaScript batch file

The OrcaScript batch file contains the following scripts:

```start session
set liblist "D:\Test\PB\170cmdvss\test11.pbl;D:\Test\PB\170cmdvss\appeontry.pbl;"
set application "D:\Test\PB\170cmdvss\test11.pbl"  "test11"
build library "D:\Test\PB\170cmdvss\test11.pbl" "" pbd
build library "D:\Test\PB\170cmdvss\appeontry.pbl" "" pbd
build executable "D:\Test\PB\170cmdvss\test11.exe" "" "" "yy" newvstylecontrols
end session```

pbc170.exe tool

Directly execute the pbc170.exe tool with the following commands:

`pbc170 /d D:\Test\PB\170cmdvss\test11.pbt`

For more about how to use the pbc170.exe tool, refer to the standalone PBC user guide (pbc.pdf) in the AutoCompile folder.

Error handling

Each line of an OrcaScript batch file either succeeds or fails. If a command fails, subsequent commands are not processed and the OrcaScript session is ended. An error message is printed to the command window.

Exception handling

User-defined exceptions such as Try...Catch is not supported by OrcaScript.