With Command

The With command allows a Variable or Array key to be specified and then referred to in shorthand. This allows statements to be focused on the item of data in question, and reduces the amount of code needed, thereby potentially reducing the opportunity for error.

There are only two commands in the With family - With and EndWith. Each With command has to have a corresponding EndWith command.

The With command consists of the command followed by a Variable reference (that is, any Variable or Array key). The EndWith command does not use an expression, and so will ignore any expression given.

For example:

{ Application.Groups.Admin.Users.157 = ["Username": "fred", "Password": "pass"] }{ with Application.Groups.Admin.Users.157 }{   .Username // Same as saying Application.Groups.Admin.Users.157.Username,
                 but shorter!
}{ endwith }


With structures can be nested indefinitely within other With structures, and within other command structures, however only the innermost With is in effect at any one time.

ptpscript/commands/with.txt · Last modified: 2007/01/24 10:15
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki