|
|
2020/4/28(Tue) 10:55:29|NO.90212
西暦を干支に変換するプログラムを作っています。
year=2020
jikkan="甲","乙","丙","丁","戊","己","庚","辛","壬","癸"
junisi="子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥"
eto=jikkan(year%10+1)+junisi(year%12+1)
mes eto
stop
これを実行すると、
eto.hsp(4) : error 4 : パラメーター式の記述が無効です (4行目)
--> eto=jikkan(year%10+1)+junisi(year%12+1)
というエラーが出てしまいます。
どうすれば正しく表示させられますか?
|
|
2020/4/28(Tue) 14:06:27|NO.90216
HSPでは剰余算は「%」じゃなくて、「\」を使用します
|
|
2020/4/28(Tue) 14:10:03|NO.90218
こんな感じです
year=2020
jikkan="甲","乙","丙","丁","戊","己","庚","辛","壬","癸"
junisi="子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥"
eto=jikkan(year\10+1)+junisi(year\12+1)
mes eto
stop
|
|
2020/4/28(Tue) 15:08:44|NO.90219
成功しました!ありがとうございます!
あと、干支がずれて出力されていたので、修正しました。
year=2020
jikkan="庚","辛","壬","癸","甲","乙","丙","丁","戊","己"
junisi="申","酉","戌","亥","子","丑","寅","卯","辰","巳","午","未"
eto=jikkan(year\10)+junisi(year\12)
mes eto
stop
|
|
2020/4/28(Tue) 15:09:47|NO.90220
解決を押し忘れました…
|
|
2020/4/29(Wed) 09:32:27|NO.90224
モジュールにしました。
//eto.as
//by ふじこlp
//
//val=eto(p1)
//西暦を干支に変換
//p1=0〜:西暦の数値(整数)
//西暦の干支表示がvalに代入されます。
//
//サンプルを実行するには #if 0を #if 1に変えて実行します。
//
#module
#defcfunc eto int year
jikkan="庚","辛","壬","癸","甲","乙","丙","丁","戊","己"
junisi="申","酉","戌","亥","子","丑","寅","卯","辰","巳","午","未"
return jikkan(year\10)+junisi(year\12)
#global
#if 0
mes "2020年の干支は "+eto(2020)+" です。"
#endif
|
|