HSPポータル
サイトマップ お問い合わせ


HSPTV!掲示板


未解決 解決 停止 削除要請

2010
0926
サイドス時計を作っているのですが3解決


サイドス

リンク

2010/9/26(Sun) 19:04:54|NO.35153

HSPを始めて一カ月です
今練習の一環として時計プログラムを組んでいます
一秒ごとに紫のバーが伸びるようにしたいのですが

repeat redraw 2 color 255,255,255 boxf color 0,0,0 年=gettime(0) 月=gettime(1) 曜=gettime(2) 日=gettime(3) 時=gettime(4) 分=gettime(5) 秒=gettime(6) m秒=gettime(7) if 曜=1 :曜="月" if 曜=2 :曜="火" if 曜=3 :曜="水" if 曜=4 :曜="木" if 曜=5 :曜="金" if 曜=6 :曜="土" if 曜=7 :曜="日" pos 0,0 mes ""+年+"年" mes " "+月+" 月" mes " "+曜+" 曜" mes " "+日+" 日" mes " "+時+" 時" mes " "+分+" 分" mes " "+秒+" 秒" + " "+m秒+" pos 84,106 : mes "ms" color 100,70,170 if 秒=0 :boxf 5,130,5,140 if 秒=1 :boxf 5,130,10,140 if 秒=2 :boxf 5,130,15,140 if 秒=3 :boxf 5,130,20,140 if 秒=4 :boxf 5,130,25,140 if 秒=5 :boxf 5,130,30,140 if 秒=6 :boxf 5,130,35,140 if 秒=7 :boxf 5,130,40,140 if 秒=8 :boxf 5,130,45,140 if 秒=9 :boxf 5,130,50,140 if 秒=10:boxf 5,130,55,140 if 秒=11:boxf 5,130,60,140 if 秒=12:boxf 5,130,65,140 if 秒=13:boxf 5,130,70,140 if 秒=14:boxf 5,130,75,140 if 秒=15:boxf 5,130,80,140 if 秒=16:boxf 5,130,85,140 if 秒=17:boxf 5,130,90,140 if 秒=18:boxf 5,130,95,140 if 秒=19:boxf 5,130,100,140 if 秒=20:boxf 5,130,105,140 if 秒=21:boxf 5,130,110,140 if 秒=22:boxf 5,130,115,140 if 秒=23:boxf 5,130,120,140 if 秒=24:boxf 5,130,125,140 if 秒=25:boxf 5,130,130,140 if 秒=26:boxf 5,130,135,140 if 秒=27:boxf 5,130,140,140 if 秒=28:boxf 5,130,145,140 if 秒=29:boxf 5,130,150,140 if 秒=30:boxf 5,130,155,140 if 秒=31:boxf 5,130,160,140 if 秒=32:boxf 5,130,165,140 if 秒=33:boxf 5,130,170,140 if 秒=34:boxf 5,130,175,140 if 秒=35:boxf 5,130,180,140 if 秒=36:boxf 5,130,185,140 if 秒=37:boxf 5,130,190,140 if 秒=38:boxf 5,130,195,140 if 秒=39:boxf 5,130,200,140 if 秒=40:boxf 5,130,205,140 if 秒=41:boxf 5,130,210,140 if 秒=42:boxf 5,130,215,140 if 秒=43:boxf 5,130,220,140 if 秒=44:boxf 5,130,225,140 if 秒=45:boxf 5,130,230,140 if 秒=46:boxf 5,130,235,140 if 秒=47:boxf 5,130,240,140 if 秒=48:boxf 5,130,245,140 if 秒=49:boxf 5,130,250,140 if 秒=50:boxf 5,130,255,140 if 秒=51:boxf 5,130,260,140 if 秒=52:boxf 5,130,265,140 if 秒=53:boxf 5,130,270,140 if 秒=54:boxf 5,130,275,140 if 秒=55:boxf 5,130,280,140 if 秒=56:boxf 5,130,285,140 if 秒=57:boxf 5,130,290,140 if 秒=58:boxf 5,130,295,140 if 秒=59:boxf 5,130,300,140 await 1 redraw 1 loop
if 秒=0 :boxf 5,130,5,140 〜 if 秒=59:boxf 5,130,300,140
をもっと簡潔にするにはどうすればいいのでしょうか?



この記事に返信する


ext

リンク

2010/9/26(Sun) 19:16:07|NO.35154


repeat redraw 2 color 255,255,255 boxf color 0,0,0 年=gettime(0) 月=gettime(1) 曜=gettime(2) 日=gettime(3) 時=gettime(4) 分=gettime(5) 秒=gettime(6) m秒=gettime(7) if 曜=1 :曜="月" if 曜=2 :曜="火" if 曜=3 :曜="水" if 曜=4 :曜="木" if 曜=5 :曜="金" if 曜=6 :曜="土" if 曜=7 :曜="日" pos 0,0 mes ""+年+"年" mes " "+月+" 月" mes " "+曜+" 曜" mes " "+日+" 日" mes " "+時+" 時" mes " "+分+" 分" mes " "+秒+" 秒" + " "+m秒+" pos 84,106 : mes "ms" color 100,70,170 repeat 60 if 秒=cnt :boxf 5,130,cnt*5,140 loop await 1 redraw 1 loop
repeat〜loopを使用すれば簡潔に出来ます。

repeat 60 if 秒=cnt :boxf 5,130,cnt*5,140 loop
この部分です。



ext

リンク

2010/9/26(Sun) 19:18:42|NO.35155


repeat redraw 0 color 255,255,255 boxf color 0,0,0 年=gettime(0) 月=gettime(1) 曜=gettime(2) 日=gettime(3) 時=gettime(4) 分=gettime(5) 秒=gettime(6) m秒=gettime(7) if 曜=1 :曜="月" if 曜=2 :曜="火" if 曜=3 :曜="水" if 曜=4 :曜="木" if 曜=5 :曜="金" if 曜=6 :曜="土" if 曜=7 :曜="日" pos 0,0 mes ""+年+"年" mes " "+月+" 月" mes " "+曜+" 曜" mes " "+日+" 日" mes " "+時+" 時" mes " "+分+" 分" mes " "+秒+" 秒" + " "+m秒+" pos 84,106 : mes "ms" color 100,70,170 boxf 5,130,秒*5,140 await 1 redraw 1 loop
また、このようにboxfの範囲に変数を使用することでの短縮も可能です。



サイドス

リンク

2010/9/26(Sun) 19:21:28|NO.35156

>ext様
こんなに単純だったんですね
解決いたしました
ありがとうございます。



ONION software Copyright 1997-2023(c) All rights reserved.