エラーになり飛べない
初心者 2013/4/29(Mon) 23:37:12|NO.53705
以下のようなものを作ったのですが、
ボタン"計算"で飛ぼうとするとエラーになります。
どこが間違っているのでしょうか。
screen 0, 570, 460, , 30, 10
*atama
cls
color 255,255,180:boxf
color 0,0,0:mes
x=110 : y=5
pos x,y
font "MMS 明朝", 20, 1
line 160,86,430,86 : line 160,87,430,87
line 50,353,430,353 : line 50,354,430,354
#module
#deffunc align str string, int type, local cx, local cy
cx = ginfo_cx : cy = ginfo_cy
pos 0, ginfo_dispy : mes string // 見えない位置に書き込む
switch type
case 1: pos cx - ginfo_mesx / 2, cy : swbreak // 中央揃え
case 2: pos cx - ginfo_mesx, cy : swbreak // 右揃え
default: pos cx, cy : swbreak // 左揃え
swend
mes string
pos cx, cy + ginfo_mesy
return
#global
x1 = 110
y1 = 100
pos x1,y1 : align "一万円", 1
pos x1,y1+25 : align "五千円", 1
pos x1,y1+50 : align "二千円", 1
pos x1,y1+75 : align "千円", 1
pos x1,y1+100 : align "五百円", 1
pos x1,y1+125 : align "百円", 1
pos x1,y1+150 : align "五十円", 1
pos x1,y1+175 : align "十円", 1
pos x1,y1+200 : align "五円", 1
pos x1,y1+225 : align "一円", 1
pos x1,y1+265 : align "現在残高", 1
#define WM_COMMAND $111
oncmd gosub *ON_COMMAND, WM_COMMAND
sdim value,, 3
objmode 2
font "MS UI Gothic", 18, 1 | 16
x2 = 200
y2 = 100
pos x2,y2 : input value(0), 65, 22
pos x2,y2+25 : input value(1), 65, 22
pos x2,y2+50 : input value(2), 65, 22
pos x2,y2+75 : input value(3), 65, 22
pos x2,y2+100 : input value(4), 65, 22
pos x2,y2+125 : input value(5), 65, 22
pos x2,y2+150 : input value(6), 65, 22
pos x2,y2+175 : input value(7), 65, 22
pos x2,y2+200 : input value(8), 65, 22
pos x2,y2+225 : input value(9), 65, 22
x3 = 335
y3 = 200
pos x3,y3 : input value(10), 60, 22
pos x3,y3+25 : input value(11), 60, 22
pos x3,y3+50 : input value(12), 60, 22
pos x3,y3+75 : input value(13), 60, 22
pos x3,y3+100 : input value(14), 60, 22
pos x3,y3+125 : input value(15), 60, 22
pos x3-60,y3+165 : input value(16), 120, 22
objmode 1
pos 480,45
objmode 2
font "MS UI Gothic", 18, 1 | 16
objsize 60,32
repeat 10
button gosub str(cnt), *INP
objskip stat, 3
loop
button gosub "BS", *INP
objskip stat, 17
objsel 0
objmode 1
objsize 30,30
pos x3+65,y3+160 : button gosub "C", *clear
objsize ,30
x4 = 360
y4 = 425
pos x4,y4 : button gosub "計算", *kekka
pos x4+140,y4 : button gosub "終了", *owari
objsize
stop
*ON_COMMAND
objsel -1
if (stat > -1) && (stat < 17) {
obj_id = stat
}
return
*INP
objsel -1
Num = stat - 17
if Num < 0 : return
if Num = 10 {
if strlen (value(obj_id)) {
value(obj_id) = strmid (value(obj_id), 0, strlen (value(obj_id)) - 1)
}
} else {
value(obj_id) + str (Num)
}
objprm obj_id, value(obj_id)
return
stop
*kekka
cls
color 255,255,180:boxf
color 0,0,0:mes
font "MMS 明朝", 20, 1
pos 240,60 : mes "枚数"
pos 400,60 : mes "合計"
line 190,86,500,86 : line 190,87,500,87
line 50,330,500,330 : line 50,331,500,331
x1 = 110
y1 = 100
pos x1,y1 : align "一万円", 1
pos x1,y1+25 : align "五千円", 1
pos x1,y1+50 : align "千円", 1
pos x1,y1+75 : align "五百円", 1
pos x1,y1+100 : align "百円", 1
pos x1,y1+125 : align "五十円", 1
pos x1,y1+150 : align "十円", 1
pos x1,y1+175 : align "五円", 1
pos x1,y1+200 : align "一円", 1
pos x1,y1+240 : align "合計金額", 1
pos x1,y1+265 : align "過不足", 1
x2 = 278
y2 = 100
pos x2,y2 : align ""+ value(0), 2
pos x2,y2+25 : align ""+ value(1), 2
pos x2,y2+50 : align ""+ (value(2)*2 + value(3)), 2
pos x2,y2+75 : align ""+ (value(4) + value(10)*50), 2
pos x2,y2+100 : align ""+ (value(5) + value(11)*50), 2
pos x2,y2+125 : align ""+ (value(6) + value(12)*50), 2
pos x2,y2+150 : align ""+ (value(7) + value(13)*50), 2
pos x2,y2+175 : align ""+ (value(8) + value(14)*50), 2
pos x2,y2+200 : align ""+ (value(9) + value(15)*50), 2
x3 = 470
y3 = 100
pos x3,y3 : align ""+ value(0) * 10000, 2
pos x3,y3+25 : align ""+ value(1) * 5000, 2
pos x3,y3+50 : align ""+ (value(2)*2+value(3)) * 1000, 2
pos x3,y3+75 : align ""+ (value(4) + value(10)*50) * 500, 2
pos x3,y3+100 : align ""+ (value(5) + value(11)*50) * 100, 2
pos x3,y3+125 : align ""+ (value(6) + value(12)*50) * 50, 2
pos x3,y3+150 : align ""+ (value(7) + value(13)*50) * 10, 2
pos x3,y3+175 : align ""+ (value(8) + value(14)*50) * 5, 2
pos x3,y3+200 : align ""+ (value(9) + value(15)*50), 2
pos x3,y3+240 : align ""+ (value(0) * 10000 + value(1) * 5000 + (value(2)*2+value(3)) * 1000 + (value(4) + value(10)*50) * 500 + (value(5) + value(11)*50) * 100 + (value(6) + value(12)*50) * 50 + (value(7) + value(13)*50) * 10 + (value(8) + value(14)*50) * 5 + (value(9) + value(15)*50)), 2
pos x3,y3+265 : align ""+ ((value(0) * 10000 + value(1) * 5000 + (value(2)*2+value(3)) * 1000 + (value(4) + value(10)*50) * 500 + (value(5) + value(11)*50) * 100 + (value(6) + value(12)*50) * 50 + (value(7) + value(13)*50) * 10 + (value(8) + value(14)*50) * 5 + (value(9) + value(15)*50))-value(16)), 2
if (((value(0) * 10000 + value(1) * 5000 + (value(2)*2+value(3)) * 1000 + (value(4) + value(10)*50) * 500 + (value(5) + value(11)*50) * 100 + (value(6) + value(12)*50) * 50 + (value(7) + value(13)*50) * 10 + (value(8) + value(14)*50) * 5 + (value(9) + value(15)*50))-value(16))>=0){color 0,0,0 : pos x3,y3+265 : align ""+ ((value(0) * 10000 + value(1) * 5000 + (value(2)*2+value(3)) * 1000 + (value(4) + value(10)*50) * 500 + (value(5) + value(11)*50) * 100 + (value(6) + value(12)*50) * 50 + (value(7) + value(13)*50) * 10 + (value(8) + value(14)*50) * 5 + (value(9) + value(15)*50))-value(16)), 2}else{color 255,0,0 :pos x3,y3+265 : align ""+ ((value(0) * 10000 + value(1) * 5000 + (value(2)*2+value(3)) * 1000 + (value(4) + value(10)*50) * 500 + (value(5) + value(11)*50) * 100 + (value(6) + value(12)*50) * 50 + (value(7) + value(13)*50) * 10 + (value(8) + value(14)*50) * 5 + (value(9) + value(15)*50))-value(16)), 2}
objsize ,30
x4 = 360
y4 = 395
pos x4+70,y4 : button "戻る", *atama
pos x4+140,y4 : button "終了", *owari
objsize
return
stop
*owari
end
KA 2013/4/30(Tue) 01:03:38|NO.53706
まず、最低限のスクリプトでエラーが出る様に、関係ない所を消しましょう。
あり 2013/4/30(Tue) 02:48:47|NO.53708
文字列型配列変数(value)を計算しているのでエラーになります。
valueを計算する部分ではintを使って整数に変換してください。
例
align ""+ (value(2)*2 + value(3)), 2
なら
align ""+ (int(value(2))*2 + int(value(3))), 2
にする