#include "ifx.h"
prototype CreateCalendar(BYREF LIST, NUMBER, NUMBER);
prototype GetDayOfWeek(NUMBER, NUMBER, NUMBER);
prototype GetEndOfMonth(NUMBER, NUMBER);
prototype IsLeapYear(NUMBER);
LIST l;
NUMBER m, y;
STRING s;
program
AskText("年を入力してください。(1-9999)", "", s);
if (StrToNum(y, s) < ISERR_SUCCESS) then abort; endif;
if (y < 1 || y > 9999) then abort; endif;
l = ListCreate(STRINGLIST);
if (l = LIST_NULL) then abort; endif;
for m = 1 to 12
CreateCalendar(l, y, m);
endfor;
SdShowInfoList("", "", l);
ListDestroy(l);
abort;
endprogram
function CreateCalendar(l, y, m)
NUMBER d, i, w;
STRING s, t;
begin
w = GetDayOfWeek(y, m, 1);
d = GetEndOfMonth(y, m);
NumToStr(s, y); t = s;
NumToStr(s, m); if (StrLength(s) = 1) then s = " " + s; endif;
ListAddString(l, t + "/" + s, AFTER); t = "";
ListAddString(l, "日 月 火 水 木 金 土", AFTER);
for i = 1 to w
t = t + " ";
endfor;
for i = 1 to d
NumToStr(s, i);
if (StrLength(s) = 1) then t = t + " " + s; else t = t + s; endif;
if (GetDayOfWeek(y, m, i) = 6 || i = d) then
ListAddString(l, t, AFTER); t = "";
else
t = t + " ";
endif;
endfor;
ListAddString(l, "", AFTER);
end;
function GetDayOfWeek(y, m, d)
begin
if (m <= 2) then y = y - 1; m = m + 12; endif;
return (5 * y / 4 - y / 100 + y / 400 + (26 * m + 16) / 10 + d) % 7;
end;
function GetEndOfMonth(y, m)
begin
switch (m)
case 1, 3, 5, 7, 8, 10, 12 : return 31;
case 2 : if (IsLeapYear(y)) then return 29; else return 28; endif;
case 4, 6, 9, 11 : return 30;
endswitch;
end;
function IsLeapYear(y)
begin
if (y % 400 = 0) then return 1; endif;
if (y % 100 = 0) then return 0; endif;
if (y % 4 = 0) then return 1; endif;
return 0;
end;
silverwire
#5154()
[
Other
]
Rating2/2=1.00
InstallShield Scriptで書いてみました。 InstallShield Scriptは Windowsアプリケーション用のインストーラーを作成するための 言語です。 インストーラーを実行すると、年を入力するダイアログが表示されます。西暦を入力して [次へ]ボタンを押すと、ダイアログに以下の形式でカレンダーが表示されます。 e.g. 2008/ 1 日 月 火 水 木 金 土 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 (中略) 2008/12 日 月 火 水 木 金 土 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 # InstallShield Profesional 7.01でビルドし、動作することを確認。#include "ifx.h" prototype CreateCalendar(BYREF LIST, NUMBER, NUMBER); prototype GetDayOfWeek(NUMBER, NUMBER, NUMBER); prototype GetEndOfMonth(NUMBER, NUMBER); prototype IsLeapYear(NUMBER); LIST l; NUMBER m, y; STRING s; program AskText("年を入力してください。(1-9999)", "", s); if (StrToNum(y, s) < ISERR_SUCCESS) then abort; endif; if (y < 1 || y > 9999) then abort; endif; l = ListCreate(STRINGLIST); if (l = LIST_NULL) then abort; endif; for m = 1 to 12 CreateCalendar(l, y, m); endfor; SdShowInfoList("", "", l); ListDestroy(l); abort; endprogram function CreateCalendar(l, y, m) NUMBER d, i, w; STRING s, t; begin w = GetDayOfWeek(y, m, 1); d = GetEndOfMonth(y, m); NumToStr(s, y); t = s; NumToStr(s, m); if (StrLength(s) = 1) then s = " " + s; endif; ListAddString(l, t + "/" + s, AFTER); t = ""; ListAddString(l, "日 月 火 水 木 金 土", AFTER); for i = 1 to w t = t + " "; endfor; for i = 1 to d NumToStr(s, i); if (StrLength(s) = 1) then t = t + " " + s; else t = t + s; endif; if (GetDayOfWeek(y, m, i) = 6 || i = d) then ListAddString(l, t, AFTER); t = ""; else t = t + " "; endif; endfor; ListAddString(l, "", AFTER); end; function GetDayOfWeek(y, m, d) begin if (m <= 2) then y = y - 1; m = m + 12; endif; return (5 * y / 4 - y / 100 + y / 400 + (26 * m + 16) / 10 + d) % 7; end; function GetEndOfMonth(y, m) begin switch (m) case 1, 3, 5, 7, 8, 10, 12 : return 31; case 2 : if (IsLeapYear(y)) then return 29; else return 28; endif; case 4, 6, 9, 11 : return 30; endswitch; end; function IsLeapYear(y) begin if (y % 400 = 0) then return 1; endif; if (y % 100 = 0) then return 0; endif; if (y % 4 = 0) then return 1; endif; return 0; end;Rating2/2=1.00-0+
[ reply ]