Qindex Programming Tips
125 [Quick Reference] Statements
written by Qindex at 2008-04-04 12:09 /

 JavaScript 1.3

 

break Terminates the current while/for loop or switch statement and transfers program control to the statement following the terminated loop.
break [label];


continue Terminates execution of the block of statements in a while or for loop, and continues execution of the loop with the next iteration.
continue [label];


do ... while Executes the specified statements until the test condition evaluates to false. Statements execute at least once.
do {
    statements
} while(condition);


export Allows a signed script to provide properties, functions, and objects to other signed or unsigned scripts.
export name1, name2, ..., nameN
export *


for Creates a loop that consists of three optional expressions, enclosed in parentheses and separated by semicolons, followed by a block of statements executed in the loop.
for([initial-expression]; [condition]; [increment-expression]) {
    statements
}


for ... in Iterates a specified variable over all the properties of an object. For each distinct property, JavaScript executes the specified statements.
for (variable in object) {
    statements
}


function Declares a function with the specified parameters. Acceptable parameters include strings, numbers, and objects.
function name([param] [, param] [..., param]){
   statements
}


if ... else Executes a set of statements if a specified condition is true. If the condition is false, another set of statements can be executed.
if(condition) {
   statements1
} [else {
   statements2
}]


import Allows a script to import properties, functions, and objects from a signed script that has exported the information.
import objectName.name1, objectName.name2, ..., objectName.nameN
import objectName.*


label Provides an identifier that can be used with break or continue to indicate where the program should continue execution.
label :
    statements


return Specifies the value to be returned by a function.
return expression;


switch Allows a program to evaluate an expression and attempt to match the expression's value to a case label.
switch(expression) {
    case label :
       statements;
       [break;]
    case label :
       statements;
       [break;]
    ...
    default : statements;
}


var Declares a variable, optionally initializing it to a value.
var varname [= value] [..., varname [= value] ];


while Creates a loop that evaluates an expression, and if it is true, executes a block of statements. The loop then repeats, as long as the specified condition is true.
while(condition) {
    statements
}


with Establishes the default object for a set of statements.
with(object){
    statements
}


Client-Side JavaScript Reference v1.3 Chapter 4 Statements

http://developer.netscape.com/docs/manuals/js/client/jsref/stmt.htm

 

 

 PHP 4

 

Alternative syntax for control structures Change the opening brace of if, while, for, foreach, and switch to a colon (:) and the closing brace to endif;, endwhile;, endfor;, endforeach;, or endswitch;, respectively.


if(condition) :
   statements
[elseif(condition) :
   statements]
[else :
   statements]
endif;


break Ends execution of the current for, foreach while, do..while or switch structure.
break;


continue Is used within looping structures to skip the rest of the current loop iteration and continue execution at the beginning of the next iteration.
continue;


declare Used to set execution directives for a block of code.
declare (directive) statements


do..while loops are very similar to while loops, except the truth expression is checked at the end of each iteration instead of in the beginning.
do {
    statements
} while(condition);


for The first expression (expr1) is evaluated (executed) once unconditionally at the beginning of the loop. In the beginning of each iteration, expr2 is evaluated. If it evaluates to TRUE, the loop continues and the nested statement(s) are executed. If it evaluates to FALSE, the execution of the loop ends. At the end of each iteration, expr3 is evaluated (executed). Each of the expressions can be empty. expr2 being empty means the loop should be run indefinitely (PHP implicitly considers it as TRUE, like C).
for (expr1; expr2; expr3) statements


foreach Works only on arrays, and will issue an error when you try to use it on a variable with a different data type or an uninitialized variables.
foreach(array_expression as $value) statements
foreach(array_expression as $key => $value) statements


if ... elseif ... else
if(condition) {
   statements
} [elseif(condition) {
   statements
}] [else {
   statements
}]


include Includes and evaluates the specific file. The script will continue regardless of a missing file.
include 'prepend.php';
include $somefile;
include('somefile.txt');


include_once Includes and evaluates the specific file. If the code from a file has already been included, it will not be included again. The script will continue regardless of a missing file.
include_once 'prepend.php';
include_once $somefile;
include_once('somefile.txt');


require Includes and evaluates the specific file. A missing file will halt processing of the page.
require 'prepend.php';
require $somefile;
require('somefile.txt');


require_once Includes and evaluates the specific file. If the code from a file has already been included, it will not be included again. A missing file will halt processing of the page.
require_once 'prepend.php';
require_once $somefile;
require_once('somefile.txt');


return
If called from within a function, the return() statement immediately ends execution of the current function, and returns its argument as the value of the function call. return() will also end the execution of an eval() statement or script file.
If called from the global scope, then execution of the current script file is ended. If the current script file was include()ed or require()ed, then control is passed back to the calling file. Furthermore, if the current script file was include()ed, then the value given to return() will be returned as the value of the include() call.
* Note that since return() is a language construct and not a function, the parentheses surrounding its arguments are not required--in fact, it is more common to leave them out than to use them, although it doesn't matter one way or the other.

return [$somevalue];
return($somevalue);


switch
switch(expression){
    case label :
       statements;
       [break;]
    case label :
       statements;
       [break;]
    ...
    default : statements;
}


while
while(expression) statements


PHP Manual Chapter 12. Control Structures http://www.php.net/manual/en/control-structures.php

 

 

 

 VBScript

 

Call Transfers control to a Sub or Function procedure. If you use the Call keyword to call a procedure that requires arguments, argumentlist must be enclosed in parentheses. If you omit the Call keyword, you also must omit the parentheses around argumentlist. If you use either Call syntax to call any intrinsic or user-defined function, the function's return value is discarded.

[Call] name [argumentlist]


Class Declares the name of a class, as well as a definition of the variables, properties, and methods that comprise the class.
Class name
   statements
End Class


Const Declares constants for use in place of literal values.
[Public | Private] Const constname = expression


Dim Declares variables and allocates storage space.
Dim varname[([subscripts])][, varname[([subscripts])]] . . .


Do...Loop Repeats a block of statements while a condition is True or until a condition becomes True.
Do [{While | Until} condition]
   [statements]
   [Exit Do]
   [statements]
Loop

Do
   [statements]
   [Exit Do]
   [statements]
Loop [{While | Until} condition]


Erase Reinitializes the elements of fixed-size arrays and deallocates dynamic-array storage space.
Erase array


Execute Executes one or more specified statements.
Execute statement


ExecuteGlobal Executes one or more specified statements in the global namespace of a script.
ExecuteGlobal statement


Exit Exits a block of Do...Loop, For...Next, Function, or Sub code.
Exit Do
Exit For
Exit Function
Exit Property
Exit Sub


For Each...Next Repeats a group of statements for each element in an array or collection.
For Each element In group
   [statements]
   [Exit For]
   [statements]
Next [element]


For...Next Repeats a group of statements a specified number of times.
For counter = start To end [Step step]
    [statements]
    [Exit For]
    [statements]
Next


Function Declares the name, arguments, and code that form the body of a Function procedure.
[Public [Default] | Private] Function name [(arglist)]
   [statements]
   [name = expression]
   [Exit Function]
   [statements]
   [name = expression]
End Function


If...Then...Else Conditionally executes a group of statements, depending on the value of an expression.
If condition Then statements [Else elsestatements ]

If condition Then
   [statements]
[ElseIf condition-n Then
   [elseifstatements]] . . .
[Else
   [elsestatements]]
End If


On Error Enables or disables error-handling.
On Error Resume Next
On Error GoTo 0


Option Explicit Forces explicit declaration of all variables in a script.
Option Explicit


Private Declares private variables and allocates storage space. Declares, in a Class block, a private variable.
Private varname[([subscripts])][, varname[([subscripts])]] . . .


Property Get Declares, in a Class block, the name, arguments, and code that form the body of a Property procedure that gets (returns) the value of a property.
[Public [Default] | Private] Property Get name [(arglist)]
   [statements]
   [[Set] name = expression]
   [Exit Property]
   [statements]
   [[Set] name = expression]
End Property


Property Let Declares, in a Class block, the name, arguments, and code that form the body of a Property procedure that assigns (sets) the value of a property.
[Public | Private] Property Let name ([arglist,] value)
   [statements]
   [Exit Property]
   [statements]
End Property


Property Set Declares, in a Class block, the name, arguments, and code that form the body of a Property procedure that sets a reference to an object.
[Public | Private] Property Set name([arglist,] reference)
   [statements]
   [Exit Property]
   [statements]
End Property


Public Declares public variables and allocates storage space. Declares, in a Class block, a private variable.
Public varname[([subscripts])][, varname[([subscripts])]] . . .


Randomize Initializes the random-number generator.
Randomize [number]


ReDim Declares dynamic-array variables, and allocates or reallocates storage space at procedure level.
ReDim [Preserve] varname(subscripts) [, varname(subscripts)] . . .


Rem Includes explanatory remarks in a program.
Rem comment
' comment


Select Case Executes one of several groups of statements, depending on the value of an expression.
Select Case testexpression
   [Case expressionlist-n
      [statements-n]] . . .
   [Case Else
      [elsestatements-n]]
End Select


Set Assigns an object reference to a variable or property, or associates a procedure reference with an event.
Set objectvar = {objectexpression | New classname | Nothing}
Set object.eventname = GetRef(procname)


Stop Suspends execution.
Stop


Sub Declares the name, arguments, and code that form the body of a Sub procedure.
[Public [Default] | Private] Sub name [(arglist)]
   [statements]
   [Exit Sub]
   [statements]
End Sub


While...Wend Executes a series of statements as long as a given condition is True.
While condition
   Version [statements]
Wend


With Executes a series of statements on a single object.
With object
   statements
End With


Visual Basic Scripting Edition Statements

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/vtoriStatements.asp



 [post]
[permission] read:Anonymous, comment:Anonymous, write:Webmaster, upload:Webmaster, manage:Webmaster
Qindex.info