The author of tbas, Antonio Maschio, loves DATA and READ statements, and after putting together a Chinese Zodiac submission for RosettaCode, I can see why. And then there's TAB() which is also very helpful.
DATA "甲","乙","丙","丁","戊","己","庚","辛","壬","癸"
DECLARE celestial$(10)
MAT READ celestial$
DATA "子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥"
DECLARE terrestrial$(12)
MAT READ terrestrial$
DATA "Rat","Ox","Tiger","Rabbit","Dragon","Snake","Horse","Goat","Monkey","Rooster","Dog","Pig"
DECLARE animals$(12)
MAT READ animals$
DATA "Wood","Fire","Earth","Metal","Water"
DECLARE elements$(5)
MAT READ elements$
DATA "yang","yin"
DECLARE aspects$(2)
MAT READ aspects$
DATA "jiă","yĭ","bĭng","dīng","wù","jĭ","gēng","xīn","rén","gŭi"
DATA "zĭ","chŏu","yín","măo","chén","sì","wŭ","wèi","shēn","yŏu","xū","hài"
DECLARE celestialpinyin$(UBOUND(celestial$(),1))
DECLARE terrestrialpinyin$(UBOUND(terrestrial$(),1))
MAT READ celestialpinyin$
MAT READ terrestrialpinyin$
DATA 1935,1938,1931,1961,1963,1991,1993,1996,2001
DECLARE years(9)
MAT READ years
DECLARE _base = 4
DECLARE _year
DECLARE cycleyear
DECLARE stemnumber
DECLARE stemhan$
DECLARE stempinyin$
DECLARE elementnumber
DECLARE element$
DECLARE branchnumber
DECLARE branchhan$
DECLARE branchpinyin$
DECLARE animal$
DECLARE aspectnumber
DECLARE aspect$
DECLARE index
DECLARE i
DECLARE top = UBOUND(years(),1)
FOR i = 1 TO top
_year = years(i)
cycleyear = _year - _base
stemnumber = MOD(cycleyear, 10)
stemhan$ = celestial$(stemnumber + 1)
stempinyin$ = celestialpinyin$(stemnumber + 1)
elementnumber = div(stemnumber, 2) + 1
element$ = elements$(elementnumber)
branchnumber = MOD(cycleyear, 12)
branchhan$ = terrestrial$(branchnumber + 1)
branchpinyin$ = terrestrialpinyin$(branchnumber + 1)
animal$ = animals$(branchnumber + 1)
aspectnumber = MOD(cycleyear, 2)
aspect$ = aspects$(aspectnumber + 1)
index = MOD(cycleyear, 60) + 1
PRINT _year;
PRINT TAB(5);stemhan$+branchhan$;
PRINT TAB(12);stempinyin$;"-";branchpinyin$;
PRINT TAB(25);element$;" ";animal$;" ("+aspect$+")";
PRINT TAB(50);"year";index;"of the cycle"
NEXT
Running the program gives
$ tbas chinZod.bas
1935 乙亥 yĭ-hài Wood Pig (yin) year 12 of the cycle
1938 戊寅 wù-yín Earth Tiger (yang) year 15 of the cycle
1931 辛未 xīn-wèi Metal Goat (yin) year 8 of the cycle
1961 辛丑 xīn-chŏu Metal Ox (yin) year 38 of the cycle
1963 癸卯 gŭi-măo Water Rabbit (yin) year 40 of the cycle
1991 辛未 xīn-wèi Metal Goat (yin) year 8 of the cycle
1993 癸酉 gŭi-yŏu Water Rooster (yin) year 10 of the cycle
1996 丙子 bĭng-zĭ Fire Rat (yang) year 13 of the cycle
2001 辛巳 xīn-sì Metal Snake (yin) year 18 of the cycle
© Copyright Bruce M. Axtens, 2018
No comments:
Post a Comment