HSPポータル
サイトマップ お問い合わせ


HSPTV!掲示板


未解決 解決 停止 削除要請

2012
0629
awq名前選択画面3解決


awq

リンク

2012/6/29(Fri) 07:13:44|NO.47421


//http://prograpark.ninja-web.net/HSP/lab/StrReplace.html //↑ここのモジュールを引用しました #module #defcfunc replace str p1, str target, str after dim len, 2 len = strlen(p1), strlen(target) sdim string, len + 1 // 置換前文字列を格納する変数を用意 string = p1 // instr するので、いったん変数に移す i = 0 // リセット repeat n = instr(string, i, target) if ( n < 0 ) { break } i += n string = strmid(string, 0, i) + after + strmid(string, i + len(1), len(0) - i) i += len(1) await 0 // とりあえずフリーズしません loop return string #global dim memmes,10 *nameselect redraw 0 color 255,255,255 : boxf //pに文字を入れとく p=" 1"," 2"," 3"," 4"," 5"," 6"," 7"," 8"," 9"," 0"," A"," B"," C"," D"," E"," F"," G"," H"," I"," J"," K"," L"," M"," N"," O"," P"," Q"," R"," S"," T" p(30)=" U"," V"," W"," X"," Y"," Z"," ,"," 。","!","?"," a"," b"," c"," d"," e"," f"," g"," h"," i"," j"," k"," l"," m"," n"," o"," p"," q"," r"," s"," t"," u"," v"," w"," x"," y"," z"," /"," _"," ―"," EN" //文字表示 repeat 10 nm=cnt pos 130+cnt*40,280 repeat 7 pms=nm+(cnt*10) if pselect=pms : color 255 : else : color 0,0,0 mes p(pms) loop loop pos 0,0 mes ssmes //選択 stick k if k=1&pselect>0 : pselect-- if k=2 : pselect-10 if k=4&pselect<69 : pselect++ if k=8: pselect+10 if k=16&pselect!69&cc!10{ ssmes+p(pselect) : memmes(cc)=p(pselect) : cc++ } if k=64&cc!0 : ssmes=replace(ssmes, memmes(cc-1), "") : cc-- if k=16&pselect=69 : end if pselect<0 : pselect+70 if pselect>69 : pselect-70 redraw 1 await 16 goto *nameselect

名前入力画面を作ろうと思ってこんなものを作りました。、
Ctrlキーを押したときにひとつ前の文字が消えるようにしたいのですが、
同じ文字をすべて消してしまいます。
一応原因は変数memmesに代入した文字をすべて消しているからなのですが、
対策がわかりません。ご教授願います。



この記事に返信する


玄冬

リンク

2012/6/29(Fri) 12:57:49|NO.47427

ここまで、きちんと作っているのに、そこでドはまりしてしまいますか…


dim memmes,10 *nameselect redraw 0 color 255,255,255 : boxf //pに文字を入れとく p=" 1"," 2"," 3"," 4"," 5"," 6"," 7"," 8"," 9"," 0"," A"," B"," C"," D"," E"," F"," G"," H"," I"," J"," K"," L"," M"," N"," O"," P"," Q"," R"," S"," T" p(30)=" U"," V"," W"," X"," Y"," Z"," ,"," 。","!","?"," a"," b"," c"," d"," e"," f"," g"," h"," i"," j"," k"," l"," m"," n"," o"," p"," q"," r"," s"," t"," u"," v"," w"," x"," y"," z"," /"," _"," ―"," EN" //文字表示 repeat 10 nm=cnt pos 130+cnt*40,280 repeat 7 pms=nm+(cnt*10) if pselect=pms : color 255 : else : color 0,0,0 mes p(pms) loop loop pos 0,0 /*足したのは↓↓*/ ssmes = "" repeat cc ssmes += memmes(cnt) loop /*↑↑だけです*/ mes ssmes //選択 stick k if k=1&pselect>0 : pselect-- if k=2 : pselect-10 if k=4&pselect<69 : pselect++ if k=8: pselect+10 if k=16&pselect!69&cc!10{ /*ssmes+p(pselect) : */memmes(cc)=p(pselect) : cc++ } if k=64&cc!0 /*: ssmes=replace(ssmes, memmes(cc-1), "")*/ : cc-- if k=16&pselect=69 : end if pselect<0 : pselect+70 if pselect>69 : pselect-70 redraw 1 await 16 goto *nameselect



玄冬

リンク

2012/6/29(Fri) 13:13:45|NO.47428

あるいは配列pの要素が!と?以外は
全て半角スペース+全角1文字に
そろえられているようですので、
!と?にも半角スペースをつけても良いのであれば


if k=64&cc!0 : ssmes= strmid(ssmes, 0, strlen(ssmes)-3) : cc--
と半角スペース+全角1文字=半角3文字分をssmesから削るのも手ですね。
これならmemmesとccが不要になるかな?(文字数制限もstrlenで賄えるので)



awq

リンク

2012/7/3(Tue) 22:12:35|NO.47475

返信遅れてすみません。

>>玄冬さん

おお!できました!
わかりにくいことだったので進展していませんでした。

ありがとうございます。これでさきに進めます。



ONION software Copyright 1997-2023(c) All rights reserved.