Best Practices in Scripting

Use the following rules when writing a SecureLogin script. Although these rules are not compulsory, they accomplish the following:

Example scripts in this guide follow these rules.


Using Capital Characters

Use capital characters where applicable.

Use This Instead of This
MessageBox "Some text" -YesNo ?Result
Messagebox "Some text" -yesno ?result


Indenting

Indent sections of scripts between pairs of commands, such as Dialog/EndDialog, Repeat/EndRepeat, and If/Else. An indent of three spaces is optimal.

Use This Instead of This
If -Text "Some text" 
#Do this
Else
#Do this
EndIf
If -Text "Some text" 
#Do this
Else
#Do This
EndIf


Leaving Blank Lines

Leave a blank line between sections of the script, such as the Dialog block and the rest of the script.

Use This Instead of This
# Login Dialog Box 
Dialog
Class #32770
Title "Login"
EndDialog

Type $Username #1001
Type $Password #1002
Click #1
# Login Dialog Box 
Dialog
Class #32770
Title "Login"
EndDialog
Type $Username #1001
Type $Password #1002
Click #1


Placing and Naming Subroutine Sections

Place subroutine sections of the script at the bottom of the script, not halfway through. The name of the subroutine should describe its function. It shouldn't simply be a numeric name. The name should follow the rules for capitalizing.


Using Quotation Marks for Text in Commands

Even if quotation marks aren't required, always use them around segments of text in commands.

Use This Instead of This
Type "Text"OrIf -Text "Login"
Type TextOrIf -Text Login


Capitalizing Variables

Begin variable names with a capital letter.

Use This Instead of This
Type $Username
Type $username


Placing Switches

Place switches directly after the command (for example, Type -Raw, If -Text).

Use This Instead of This
Type -Raw $Username
Type $Username -Raw


Password Policy Names

Use program names to represent password policy names for the program they are used for. Don't use numerical names.

Use This Instead of This
GroupwisePasswordPolicy
PasswordPolicy3


Hiding Variables

If you want to hide a variable from an administrator by displaying the variable as **** instead of clear text, begin the variable name with $Password. For example, $PasswordPIN will be protected, but $PIN won't be protected.


Using Comments

Use comments throughout the script to explain what each section does and how it does it. At the top of the script, enter and comment out information such as who wrote the script and the date that the script was last modified.

NOTE:  To help explain example scripts in the SecureLogin Commands section, this Guide places explanations to the left of the scripts. For example, see Example: Windows Script in AAVerify.

Use This Instead of This
#Written by M. Kurz June 7, 2002 
#Modified by C. Bertrand July 3, 2004
#Login Dialog Box 
Dialog
Class #32770
Title "Login"
EndDialog
Dialog 
Class #32770
Title "Login"
EndDialog


Using the Include Command

Wherever possible, use the Include command to create generic scripts for commonly used elements, such as password change procedures. For common processes within the script, use subroutines.