Before calling any other ORCA functions, you need to open a session:
start session
You can start and end multiple OrcaScript sessions in the same batch file.
If you want to use OrcaScript simply to move objects among libraries, you do not need to set a library list or application. You can use the copy commands to copy files, objects, and properties. This example copies the d_labels DataWindow from the source.pkl library to the destin.pkl library:
copy entry "c:\\app\\source.pkl" "d_labels" dw "c:\\app\\destin.pkl"
If you want to use OrcaScript to build targets or deploy components, you must first set the library list and the current application. You can set the library list and current application only once in an OrcaScript session. To use another library list and application, end the OrcaScript session and start a new session. The following OrcaScript commands build target libraries and compile an executable file:
start session set liblist ".\qadbtest\qadbtest.pkl;.\shared_obj\shared_obj.pkl; .\datatypes\datatype.pkl;.\chgreqs\chgreqs.pkl" set application ".\qadbtest\qadbtest.pkl" "qadbtest" build library ".\shared_obj\shared_obj.pkl" "" RTLib build library ".\datatypes\datatype.pkl" "" RTLib build library ".\chgreqs\chgreqs.pkl" "" RTLib build executable ".\qadbtest\qadbtest.exe" ".\emp.ico" ".\qadbtest.pkr" "nyyy" ARM file copy ".\qadbtest\qadbtest.exe" ".\bin\qadbtest.exe" Clobber Always file copy ".\chgreqs\chgreqs.pkd" ".\bin\chgreqs.pkd" Clobber Always file copy ".\datatypes\datatype.pkd" ".\bin\datatype.pkd" Clobber Always file copy ".\shared_obj\shared_obj.pkd" ".\bin\shared_obj.pkd" Clobber Always
end session
You can use relative paths when you generate PKDs with the RTLib option, but the PKD always gets generated in the same directory as the PKL. To actually run the executable, you might have to move the PKDs to a “BIN” directory. The above example calls several file copy commands to accomplish this.
You can use OrcaScript source control commands instead of the commands to set the library list and application. The following is an example of an OrcaScript session that builds the same libraries as the previous example, but uses the target properties to set a library list and application:
start session scc get connect properties "c:\testbld\testbld.pkw" scc connect scc set target "c:\testbld\qadbtest\qadbtest.pkt" "outofdate exclude_checkout" scc refresh target "incremental" build library ".\shared_obj\shared_obj.pkl" "" pkd build library ".\datatypes\datatype.pkl" "" pkd build library ".\chgreqs\chgreqs.pkl" "" pkd build executable ".\qadbtest\qadbtest.exe" ".\emp.ico" ".\qadbtest.pkr" "nyyy" scc close end session
You can call the scc connect command only after getting connection properties, and you must call it before you set or refresh the source-controlled targets. You must call the scc close command before you end your OrcaScript session.
If you have another target that shares libraries with a target that you already refreshed, you can use the OrcaScript exclude command to quickly reconstitute your target. The following example excludes the shared libraries shared_obj.pkl, datatype.pkl, and chgreqs.pkl that were refreshed in the previous example. It also demonstrates the use of variables for refresh options and build type. Set statements define variables that can be used throughout an OrcaScript session wherever the parser expects a string token.
start session set refresh_flags = "outofdate"
set refresh_flags += "exclude_checkout" set build_type = "incremental" scc get connect properties "c:\testbld\testbld.pkw" scc connect scc set target ".\dbauto\dbauto.pkt" refresh_flags scc exclude liblist ".\shared_obj\shared_obj.pkl" ".\datatypes\datatype.pkl" ".\chgreqs\chgreqs.pkl" scc refresh target build_type build executable ".\dbauto\dbauto.exe" ".\emp.ico" "" "nyyy" ARM scc close end session
Defining variables from the command line Instead of defining variables in the OrcaScript session, you can define them from the command line when you call your script. If you saved the OrcaScript example in the previous script in a file named MyExample.dat, you could set the same variables by typing the following at a command line prompt:
pkorca15 /D refresh_flags="outofdate exclude_checkout" /D build_type="incrementral" MyExample.dat
The SCC get connect properties command is an easy way to populate the Orca SCC connection structure with the source control properties of a local workspace. However, to create OrcaScript batch files that are portable from one workstation to another, the recommended technique is to set each property explicitly. Many of these properties are vendor specific. The best way to obtain correct values is to copy them directly from the SCC log file for your PocketBuilder workspace.
After you have obtained the values you need from the SCC log file, you can create portable batch files by setting the required connection properties and using relative directories and URLs for path information. The following example shows portable OrcaScript batch file commands for a workspace that connects to PBNative:
start session scc set connect property provider "PB Native" scc set connect property userid "Jane" scc set connect property localprojpath ".\" scc set connect property project "\\network_machine\PBNative_Archive\qadb" scc set connect property logfile ".\MyPortableExample.log" scc set connect property logappend "FALSE" scc set connect property deletetempfiles "FALSE" scc connect ; Perform refresh and build operations scc close end session
If you share an OrcaScript batch file with colleagues, make sure that the userid value for the scc set connect property userid command is set for each user.
You can call scc connect offline
to
build source control targets offline. When you use this command,
you must specify ImportOnly as a refresh option. If you also specify
the Refresh_all option or the OutOfDate or Exclude_checkout
refresh types, no connection is made to source control.
For the OutOfDate refresh type, the object source residing
in the PKL is compared with the object source on the local project
path. If these object sources are different, the object source
on the local project path is imported and compiled. For the Exclude_checkout
refresh type, the workspace PKC file is used to determine current
status. In order for the offline exclude_checkout processing
to locate the PKC file, you must use the scc get
connect properties
workspaceName command
at the beginning of the script. Objects marked as checked out to
the current user in the PKC file will not be imported into the PKLs
during target processing.
For more information on PKC files, see Chapter 5, “Using Source Control.”
Applicable scc connect properties for offline processing
When scc connect offline
is
used, only the following connect properties apply:
scc set connect property localprojpath
localProjectPath
scc set connect property logfile
logFileName
scc set connect property logappend
<true | false>
OrcaScript build commands for an executable or a library fail if the executable or library already exists in the build directory. To prevent an OrcaScript batch file containing these commands from failing, move or delete existing executables and libraries from the build directory before running the batch script.
OrcaScript, like PowerScript, uses the tilde ( ~ ) as an escape character. If you need to include a special character, such as a quotation mark, inside a string, you must place a tilde in front of it. A character in an OrcaScript batch file with a tilde in front of it is processed as a literal character.
The following example builds executables for three different PocketBuilder deployment platforms:
start session set liblist "c:\pkapps\dbpaint\dbpaint.pkl;c:\pkapps\dbpaint\mlshared.pkl"
set application "c:\pkapps\dbpaint\dbpaint.pkl" dbpaint
; build library "c:\pkapps\dbpaint\mlshared.pkl" "" rtlib file copy "c:\pkapps\dbpaint\mlshared.pkd" "c:\pkapps\dbpaint\desktop\mlshared.pkd" CLOBBER ALWAYS file copy "c:\pkapps\dbpaint\mlshared.pkd" "c:\pkapps\dbpaint\arm\mlshared.pkd" CLOBBER ALWAYS file copy "c:\pkapps\dbpaint\mlshared.pkd" "c:\pkapps\dbpaint\sparm\mlshared.pkd" CLOBBER ALWAYS ;
build executable "c:\pkapps\dbpaint\desktop\dbpaint.exe" "c:\pkapps\emp.ico" "" "ny" DESKTOP build executable "c:\pkapps\dbpaint\arm\dbpaint.exe" "c:\pkapps\emp.ico" "" "ny" ARM build executable "c:\pkapps\dbpaint\sparm\dbpaint.exe" "c:\pkapps\emp.ico" "" "ny" SPARM ; end session
You must close an OrcaScript session after you finish calling other OrcaScript commands. You close an OrcaScript session by calling:
end session
Property values are deleted during end-session processing. If an OrcaScript program starts numerous sessions, each individual session must contain statements to specify property values, such as those assigned in set exeinfo or scc set connect commands. However, variables that you set on a batch script command line using the /D parameter, or inside a batch file using the set variable_name=”value” syntax, remain valid for the entire multisession program.