|
|
2018/10/27(Sat) 20:33:53|NO.85734
.txt等から文字列をひっぱってくるツールを作りたいのですが、改行を判別できず困っています
script.hsp
notesel a
noteload "color.txt"
dim colors,notemax,3
get=""
all=-1
screen 0,640,768,0,0,0
repeat notemax*14
redraw 0
//
color 255,255,255:boxf
//
rec=ind
if strmid(a, cnt, 1)=","{ind+}
if ind\3=0{all+}
if ind=rec{get+strmid(a, cnt, 1)}else{get=""}
;rm_crlf get
colors(all/6,ind\3)=int(get)
//
pos 0,0
color
mes ind\3
mes "max : "+(all/6)+" / "+notemax
mes "out : "+int(get)
pos 200,0
color 255
mes strmid(a,0, cnt)
pos 400,0
repeat notemax
mes ""+colors(cnt,0)+" : "+colors(cnt,1)+" : "+colors(cnt,2)
loop
//
redraw 1
await 100
loop
color.txt
000,000,000,
255,255,255,
127,127,127,
195,195,195,
136,000,021,
185,122,087,
237,028,036,
255,174,201,
255,127,039,
255,201,014,
255,242,000,
239,228,176,
034,177,076,
181,230,029,
000,162,232,
153,217,234,
063,072,204,
112,146,190,
163,073,164,
200,191,231,
改行を検知するにはどうすればいいでしょう
|
|
2018/10/27(Sat) 21:21:11|NO.85735
やりたいことと違ってたらすみません。
テキストファイルの中身からRGBを読みたいという感じでしたので、少し改善したものを書きました。
notesel a
noteload "color.txt"
dim colors,notemax,3
screen 0,640,768,0,0,0
pos 0,0
repeat notemax ;なぜ14倍の繰り返し数だった? 各行読むから行数で十分
redraw 0
//
;color 255,255,255:boxf
//
notesel a
b=""
noteget b,cnt ;1行ずつ読み込む
_strsize=0 ;各行のカンマまで読み込んだ数
i=cnt ;2個めのrepeatで1個めのrepeatのcnt数を使うため代入。いわゆるカウンタ変数
repeat 3 ;RGB? だから3回
buf_color="" ;getstr命令は数値型代入が出来ないので間に入る変数を用意する
getstr buf_color,b,_strsize,',',3 ;getstrで読み込む。','でカンマまでを読む
_strsize+=strsize+1 ;読み込んだ文字数を代入。カンマは含まれないので1足す
colors(i,cnt)=int(buf_color) ;間に入った内容を数値化してcolorsに代入
loop
color 0
;見た目が汚くなるから3桁に変換して表示。"%03d" は [% + (0+桁数) + d(10進数)] を意味する
mes ""+strf("%03d",colors(cnt,0))+","+strf("%03d",colors(cnt,1))+","+strf("%03d",colors(cnt,2))+""
//
redraw 1
await 100
loop
|
|
2018/10/28(Sun) 10:28:11|NO.85743
notesel a
noteload "color.txt"
screen 0,640,768,0,0,0
repeat notemax
//改行コードまで読む
getstr buf, a, n
n + strsize
//カンマ以外を取り出す
split buf, ",", results
mes strf("%03d:%03d:%03d", results(0),results(1),results(2))
loop
|
|
2018/11/1(Thu) 07:56:21|NO.85760
ありがとうございます。
(結局RGBだけで近似色を得ることができなかったのでお陀仏になってしまいました…申し訳ない)
|
|