The scripting language has one type of conditional statement - the IF..THEN..ELSE statement. The syntax of this statement is as follows:
IF <expression> THEN
<statement block>
[ELSE
<statement block>]
ENDIF
You can use the conditional statement without ENDIF, if the whole statement fits into one line:
IF <expression> THEN <statement block>
The result of the expression must be of type Integer.
Note: Instead of ENDIF you can use End If.
Another form of the conditional statement deals with nested conditional statements. Instead of coding nested conditional statements as shown in the first code sample that follows, you can code them as shown in the second sample.
DIM os As String
.
.
.
If os = "AIX" Then
aixRun()
Else
if os = "HPUX" Then
rc = hpRun()
Else
if os = "SOLARIS(sparc)" Then
solarisRun()
else
print("unknown os type: " + os)
End If
End If
End If
.
.
.
Second sample:
DIM os As String
.
.
.
If os = "AIX" Then
aixRun()
Elseif os = "HPUX" Then
hpRun()
Elseif os = "SOLARIS(sparc)" Then
solarisRun()
else
print("unknown os type: " + os)
End If
.
.
.
Example:
DIM ProgName as String DIM ProgPath as String ProgPath="C:\AVIRUS" IF InStr(ossystem,"DOS") THEN ProgName=ProgPath + "FINDVIRU.EXE" ELSE ProgName=ProgPath + "WFINDVIR.EXE" ENDIF end:
|
Copyright © 2014 CA Technologies.
All rights reserved.
|
|