Under the Bridge

a Picture of the Late Him

MT4:世界のナベアツをテンプレートタグで表現

2008年3月17日 23:23 | Writer: yoshi | 記事本文 | コメント(0) | トラックバック(0)

お題:「40までの数字を数え、3の倍数と3のつく数の時アホっぽくなり、5の倍数のとき犬っぽくなるループをMT4テンプレートタグで表現してください」

JavaScriptようわからんのでアレだが、違う言葉を発するようにしてみた。ifを多用したコードは冗長であまり良くない。htmlソース見るの禁止

動作させてみる

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

ソース

<MTSetVarBlock name="aho">
<SCRIPT language="JavaScript">
<!--
var count =(Math.floor(Math.random() * 10));
switch(count) {
case 0:document.write("ふゃあ"); break;
case 1:document.write("ふぉあ"); break;
case 2:document.write("ふぇあ"); break;
case 3:document.write("ふぁああ"); break;
case 4:document.write("にゃあ"); break;
case 5:document.write("みゃあ"); break;
default:document.write("びゃあ");break;
}//-->
</SCRIPT>
</MTSetVarBlock>

<MTSetVarBlock name="inu">
<SCRIPT language="JavaScript">
<!--
var count =(Math.floor(Math.random() * 10));
switch(count) {
case 0:document.write("バウ"); break;
case 1:document.write("ワウ"); break;
case 2:document.write("バワウ"); break;
case 3:document.write("ワソ"); break;
case 4:document.write("ワワン"); break;
case 5:document.write("キャン"); break;
default:document.write("ワン");break;
}//-->
</SCRIPT>
</MTSetVarBlock>

<mt:for var="x" from="1" to="40">
<MTSetVar name="Var" value="$x">
<MTIf name="x" like="3">
   <MTSetVar name="Var" value="$aho" append="1">
<MTElse>
   <MTIf name="x" op="%" value="3" eq="0">
      <MTSetVar name="Var" value="$aho" append="1">
   </MTIf>
</MTIf>
<MTIf name="x" op="%" value="5" eq="0">
  <MTSetVar name="Var" value="$inu" append="1">
</MTIf>
<p><MTGetVar name="Var"></p>
</mt:for>

トラックバック(0)

このブログ記事を参照しているブログ一覧: MT4:世界のナベアツをテンプレートタグで表現

このブログ記事に対するトラックバックURL:

コメントする






Categories
Entries
Feed
スポンサードリンク

parts

フィードメーター - Under the Bridge

あわせて読みたい

なかのひと

2008 yoshi(apstar)