hsp3.2でcsvを読み込む。
小松菜屋HAtaです。HSP3.2で文字列関係の命令が増えたので、随分csvの扱いが簡単になるかなあと思ってサンプルソースさがしたんだけど見つからず、すげえ昔のうすあじさんのソースが出てきたので修正して使ってみました。
↓元ソース
http://hspcenter.com/hsptvm/archives/2006/07/hsp11_csv.html#
↓HSP3.2版
;csvread_32.hsp ;読み込み sdim buf,10000 notesel buf noteload "test.dat" sdim a,100,100 repeat notemax cy=cnt noteget tmp,cnt sdim t,100,100 split tmp,",",t repeat 6 cx = cnt a(cx,cy)=strtrim(t(cx)) loop loop ;表示 repeat notemax cy=cnt repeat 6 cx=cnt pos cx*100,cy*20:color 0,0,0 if cx=1:color 200,0,0 mes a(cx,cy) loop loop stop
test.datは同じのでよいです
1,青木,5,6,8,9 0,石田,8,9,4,7 5,植村,8,9,7,9 3,江崎,8,7,9,2 2,小野寺,7,9,6,3
あれえ(trim以外)苦労あんま変わらないよー、もっと巧い方法あったら教えてください。
でもhspda.asとhspda.dllから解放されるのはとて良いです(’’;