switch case

By | 2015-10-19

 

switchcase

透過switch..case的語法,可以在一個變數的數值不一樣時,往不同的流程進行,例如要計算外資過去十天買超超過七天時,可以運用以下的語法來寫腳本 :

範例:外資近日買超天數比例

1//1.宣告參數:利用input宣告輸入的參數。
2
3input:day(10);//過去幾天
4
5input:ratio(0.7);//外資買超的天數佔多少比例
6
7//2.宣告變數,利用variable
8
9value1=GetField("Fdifference");//外資買賣超
10
11variable:count(0);
12
13variable:xi(0);
14
15for xi= 1 to day
16
17begin
18
19//============================================
20
21switch(value1[xi])
22
23begin
24
25case >0:count=count+1;
26
27case <0:count=count;
28
29case 0:count=count;
30
31end;//所有case都表達完之後,最後必須加end;來表示各種數值選項已結束
32
33//============================================
34
35end;
36
37//6.設定警示條件:if.. then ret=1;
38
39if day<>0 and count/day>=ratio
40
41then ret=1;