|
public months[]={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
table = "E:\\测试\\现场监控\\历史数据字典\\default.xls";
rc = ddt_open(table, DDT_MODE_READWRITE);
if (rc!= E_OK && rc != E_FILE_OPEN)
pause("Cannot open table.");
set_window ("YSS2000现场监控管理系统_1", 2);
menu_select_item ("数据管理;历史数据字典");
if(win_exists("历史数据字典")!=E_OK)
report_msg("历史数据字典窗口显示出现错误");
set_window ("历史数据字典", 1);
calendar_get_selected ("Date Time_0",dates, count);
length(dates);#得到时间格式:1-Jan-2005
for(a=1;a<length(dates);a++)
{
if(substr(dates, a,1)=="-")break;
}
if(a==2)
{
current_date=substr(dates, 1,1);#得到现在的日在1-9
current_month=substr(dates, 3,3);#得到现在的月
current_year=substr(dates, 7,4);#得到现在的年
}
else
{
current_date=substr(dates, 1,2);#得到现在的日大于9
current_month=substr(dates, 4,3);#得到现在的月
current_year=substr(dates, 8,4);#得到现在的年
}
#ddt_val(table, "time");
#ddt_val(table, "date");
k=1;
for(i = 1; i<=12; i++)
{
if(months[i-2]==current_month && current_date==j-1)
break;
switch(i)
{
case 2: a=28;break;
default:
if(i%2||i==8||i==10||i==12&&i!=11)
a=31;
else
a=30;
break;
}
for(j = 1; j<= a; j++)
{
if(months[i-1]==current_month && current_date==j-1)
break;
value=j&"-"&months[i-1]&"-"¤t_year;
ddt_set_val_by_row ( table, k, "date",value );
k++;
}
}
ddt_save(table);
ddt_close(table);
set_window ("历史数据字典", 1);
win_close("历史数据字典"); |
|