Job Management Partner 1/Software Distribution Administrator's Guide Volume 1

[Contents][Glossary][Index][Back][Next]

Appendix D.2 Statements

This section explains the statements used for coding JP1/Software Distribution installation script and collection script. With these statements, you can declare variables or change the program flow.

The following table lists the statements.

Table D-1 List of statements

Statement Function
Dim Declares a variable.
ErrorExit Terminates a script execution abnormally.
Exit Terminates a script execution normally.
Function Declares the beginning of a script.
End Function Declares the end of a script.
Goto Jumps to a label.
If-Then-Else-End If Tests a given condition.
On InstallError-Do-End Declares postprocessing if an error occurs during the execution of a collection script.
On CollectionError-Do-End Declares postprocessing if an error occurs during the execution of an installation script.
Rem Writes a comment.

Note that the alphabetical letters used in a statement are case sensitive.

To separate statement descriptors, you can use a space, tab, or line feed character. In a Rem statement, use one or more spaces or a tab character as a delimiter. Two or more spaces or a line feed code causes an error.

Organization of this subsection
(1) Dim statement
(2) ErrorExit statement
(3) Exit statement
(4) Function statement
(5) End Function statement
(6) Goto statement
(7) If-Then-Else-End If statement
(8) On InstallError-Do-End statement
(9) On CollectionError-Do-End statement
(10) Rem statement

(1) Dim statement

(a) Format
Dim variable-name As variable-type
(b) Description

The Dim statement declares a variable. Code this statement just after a Function statement.

(2) ErrorExit statement

(a) Format
ErrorExit
(b) Description

The ErrorExit statement terminates the execution of a script abnormally. Installation or collection can be terminated at any time. If you want to make the script report a specified status code, set the status code using the SetStatus function before the ErrorExit statement.

(3) Exit statement

(a) Format
Exit
(b) Description

The Exit statement terminates the execution of a script normally.

(4) Function statement

(a) Format
Function main()
(b) Description

The Function statement declares the beginning of a script. This statement must be used in pairs with an End Function. The statements between Function and End Function are processed as a script.

Function can be followed by only main().

(c) Notes

The script between Function and End Function cannot contain the following statements:

(5) End Function statement

(a) Format
End Function
(b) Description

The End Function statement declares the end of a script that begins with the Function statement.

(6) Goto statement

(a) Format
Goto label-name
(b) Description

Makes the script processing jump to the label denoted by label-name. A jump cannot be made into any of the following statements:

A jump must always be a jump to a statement after the current statement. Note that a loop involving a jump to a prior statement cannot be coded.

(c) Example
Goto Label01
    :
Label01:           ' (The label must be followed by a colon (:).)
    statements

(7) If-Then-Else-End If statement

(a) Format
If condition
Then
statements-to-be-executed-when-the-condition-is-true
Else
statements-to-be-executed-when-the-condition-is-false
End If
(b) Description

This statement evaluates the condition and makes the script processing branch depending on the result of the evaluation.

(c) Notes

The statements following Then or Else cannot contain the following statements:

(8) On InstallError-Do-End statement

(a) Format
On InstallError
    Do
        any-postprocessing
    End
(b) Description

In this statement, code the statements for the postprocessing if an error occurs during execution of an installation script.

The functions for JP1/Software Distribution such as Install() and Shell() immediately terminate the script if an error occurs. Therefore, the return value of the functions cannot be checked by the installation script. In this case, if postprocessing is necessary, describe the necessary processing in an On InstallError statement. The On InstallError statement can be applied to displaying a specific message on the console or outputting it to a log file at the occurrence of an installation error.

If an error occurs during the postprocessing described in the On InstallError statement, the subsequent statements are not processed and the script is terminated.

The On InstallError statement can be coded anywhere in an installation script after the Dim statement. However, for readability, code it just after the Dim statement if possible.

(c) Example
Function main()
      :
    On InstallError
    Do
        LogFile("Error occurred during installation.")
    End
      :
      :
    Install("c:\")
      :
End Function
(d) Notes

The postprocessing cannot contain the following:

(9) On CollectionError-Do-End statement

(a) Format
On CollectionError
    Do
        any-postprocessing
    End
(b) Description

In this statement, code the statements for the postprocessing if an error occurs during the execution of a collection script.

The functions for JP1/Software Distribution such as Collection() and Shell() immediately terminate the script if an error occurs. Therefore, the return value of the functions cannot be checked by the collection script. In this case, if postprocessing is necessary, code the necessary processing in an On CollectionError statement. The On CollectionError statement can be applied to outputting a specific message to a log file at the occurrence of a collection error.

If an error occurs during the postprocessing described in the On CollectionError statement, the subsequent statements are not processed and the script is terminated.

The On CollectionError statement can be coded anywhere in an installation script after the Dim statement. However, for readability, code it just after the Dim statement if possible.

(c) Example
Function main()
      :
    On CollectionError
    Do
        LogFile("Error occurred during collection.")
    End
      :
      :
    Collection("c:\users\default\user.data")
      :
End Function
(d) Notes

The postprocessing cannot contain the following:

(10) Rem statement

(a) Format
Rem comment
' comment
(b) Description

You can code your comment in a script using the Rem statement. The portion from the single quotation mark (') or Rem up to the next return code is assumed to be a comment. You can code a comment anywhere in the script file.