dingsir的个人博客分享 http://blog.sciencenet.cn/u/dingsir

博文

TGDZ 不同语言计算, 增加一种新语言AHK v2

已有 1520 次阅读 2023-10-5 22:38 |个人分类:软件杂谈|系统分类:论文交流

21. AutoHotKey  v2

;Ctrl+Alt+Y 用于计算年份Year

^!y::
{
tmpyear:=0
year :=InputBox("请输入公元多少年:","输入年份","W200 H100","2023").value
if year=0
{
MsgBox "年份不能为0","错误"
return
}
else
{
if year>0
  tmpyear := year-4
else
  tmpyear :=year-3
}
while tmpyear<0
{
tmpyear += 60
}

tg := Mod(tmpyear,10)+1
dz :=Mod(tmpyear, 12)+1
tgStr:="甲乙丙丁戊己庚辛壬癸"
dzStr:= "子丑寅卯辰巳午未申酉戌亥"
tgdz:=SubStr(tgStr,tg,1) . SubStr(dzStr,dz,1)
MsgBox year . "=>" . tgdz, "计算结果"
}


;Ctrl+Alt+T 用于计算天干地支(TGDZ),
^!t::
{
tgdz :=InputBox("请输入天干地支,限两个汉字:","Input","W200 H100","甲子").value
if StrLen(tgdz) !=2
{
MsgBox "Length of Input must be 2 chars"
return
}

baseYear:=InputBox("请输入或确认甲子元年:","确认","W200 H100","1924").value
if BaseYear>=4
{if Mod(BaseYear-4,60)!=0
{
MsgBox "甲子年起始年份不正确","错误"
return
}
}
else
{  
 tmpBaseYear:=BaseYear
 while tmpBaseYear<0
 {
 tmpBaseYear +=60
 }
 if Mod(tmpBaseYear-3, 60)!=0
{
MsgBox "甲子年起始年份不正确","错误"
return
}
}
tgStr:="甲乙丙丁戊己庚辛壬癸"
dzStr:= "子丑寅卯辰巳午未申酉戌亥"
tgIndex:=InStr(tgStr,SubStr(tgdz,1,1))-1
dzIndex:=InStr(dzStr,SubStr(tgdz,2,1))-1
if (tgIndex<0) or (dzIndex<0)
{
MsgBox "天干或地支中至少一个写错了",'错误'
return
}
m:=tgIndex-dzIndex
if m<0
{
m +=12
}
year:= BaseYear + 5*m + tgIndex
MsgBox tgdz "(基于" BaseYear ")=>" year,'计算结果'
}

; 2023-9-28 用AutoHotKey v2测试通过.

tgdz.zip


汇总不同语言的表述,见

TGDZ in 21 languages(2023-9-28).md



https://blog.sciencenet.cn/blog-1213210-1404796.html

上一篇:ASCII码与汉字的机内码、GBK码、18030编码及Uncode编码--我的粗浅理解
下一篇:甲基锂盐和超酸锂盐
收藏 IP: 112.224.172.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-11-23 21:27

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部