モジュール変数を利用し、ドラッグできるカラフルな矩形を表示します。メインループを使わない完全なイベントドリヴン形式であることも特徴です。
2007/09/05:コメントなど微調整。// ドラッグできる矩形
// マウスカーソル変更用命令(参考:http://lhsp.s206.xrea.com/hsp_mouse.html#3)
#uselib "user32"
#cfunc LoadCursor "LoadCursorA" nullptr, int
#func SetClassLong "SetClassLongA" int, int, int
// ウィンドウメッセージ
#const WM_LBUTTONDOWN 0x0201
#const WM_LBUTTONUP 0x0202
#const WM_MOUSEMOVE 0x0200
// LoadCursor用引数
#const IDC_ARROW 0x7F00
#const IDC_HAND 0x7F89
//
// 矩形を扱うモジュール
#module mdl_rect x, y, w, h, c
#const BORDER_WIDTH 2
#modinit int _x, int _y, int _w, int _h, int _c
x = _x : y = _y
w = _w : h = _h
c = _c \ 192
return
//
// 矩形を描画
#modfunc draw_rect
hsvcolor c, 255, 191
boxf x, y, x + w, y + h
hsvcolor c, 255, 255
boxf x + BORDER_WIDTH, y + BORDER_WIDTH, x + w - BORDER_WIDTH, y + h - BORDER_WIDTH
return
//
// 矩形を移動
#modfunc move_rect int _x, int _y
x = _x : y = _y
return
//
// 点(px, py)が矩形内にあるか否かを返す
#modfunc point_rect int px, int py
return ( x <= px ) & ( y <= py ) & ( px < x + w ) & ( py < y + h )
//
// 矩形のX座標を返す
#modfunc get_x var ret
ret = x
return
//
// 矩形のY座標を返す
#modfunc get_y var ret
ret = y
return
//
// 今ポイントしている矩形を調べ、その配列要素番号をstatに返す(なにもない時は-1)
#deffunc get_pointing_rect array rects, local result
result = -1
foreach rects
point_rect rects( cnt ), mousex, mousey
if stat : result = cnt ; break
loop
return result
#global
*init
// 乱数初期化
randomize
// Windowsメッセージ割り込み実行指定
oncmd gosub *LButtonDown, WM_LBUTTONDOWN
oncmd gosub *LButtonUp, WM_LBUTTONUP
oncmd gosub *MouseMove, WM_MOUSEMOVE
// 矩形を5つ作成
repeat 5
w = rnd( 100 ) + 100 : h = rnd( 100 ) + 50
newmod rects, mdl_rect, rnd( ginfo_winx - w ), rnd( ginfo_winy - h ), w, h, rnd( 191 )
loop
// マウスカーソルの種類を記録する変数を初期化
cursor_type = IDC_ARROW
// 画面の更新
gosub *renew_screen
stop
//
// 画面の更新
*renew_screen
redraw 0
color 255, 255, 255 : boxf
foreach rects
draw_rect rects( cnt )
loop
redraw 1
return
//
// マウスの左ボタンを離した時の処理
*LButtonUp
dragging = 0 // ドラッグ終了
return
//
// マウスの左ボタンを押した時の処理
*LButtonDown
if ( pointing_rect >= 0 ) {
// 矩形をポイントしている場合はその矩形をドラッグする
dx = mousex : dy = mousey
dragging = 1
}
return
//
// マウスが動いたときの処理
*MouseMove
if ( pointing_rect >= 0 ) & ( cursor_type != IDC_HAND ) {
// 矩形の上ではカーソルを手の形に変更
cursor_type = IDC_HAND
gosub *ChangeCursor
}
if ( pointing_rect < 0 ) & ( cursor_type != IDC_ARROW ) {
// 矩形の外ではカーソルを通常の形に変更
cursor_type = IDC_ARROW
gosub *ChangeCursor
}
if dragging {
// ドラッグ中ならば矩形を移動
get_x rects( pointing_rect ), x
get_y rects( pointing_rect ), y
move_rect rects( pointing_rect ), x + mousex - dx, y + mousey - dy
dx = mousex : dy = mousey
} else {
// ドラッグ中でないならばポイントしている矩形を調べる
get_pointing_rect rects
pointing_rect = stat
}
// 画面を更新
gosub *renew_screen
return
//
// マウスカーソルの変更
*ChangeCursor
SetClassLong hwnd, -12, LoadCursor( cursor_type )
mouse // マウスカーソルの更新(これがないと即座に反映されない)
return
2007年9月3日月曜日
ドラッグできる矩形の表示
2007年8月24日金曜日
リアルタイムシミュレーションっぽい動き
リアルタイムシミュレーションのように各キャラクタに対して移動指示を出し、移動させるサンプル。
配列を利用すれば、移動目標を複数保持してジグザグに移動させることも可能でしょう。JavaのVectorのような可変長配列が使えれば実装は楽そうですが……。
【操作方法】
キャラクタをクリックしてから他の地点をクリックすると、その地点めがけてキャラクタが移動を開始します。
他のキャラクタをクリックするまでキャラクタの選択状態は変更されません。#define fillbox( %1, %2, %3 ) boxf %1 - %3 / 2, %2 - %3 / 2, %1 + %3 / 2, %2 + %3 / 2
#define drawbox( %1, %2, %3 ) line %1 - %3 / 2, %2 + %3 / 2, %1 - %3 / 2, %2 - %3 / 2 %c line %1 + %3 / 2, %2 + %3 / 2 %c line %1 + %3 / 2, %2 - %3 / 2 %c line %1 - %3 / 2, %2 - %3 / 2
#const CHARACTER_SIZE 32 // キャラクタの大きさ
#const CHARACTER_NUM 5 // キャラクタの個数
#const CHARACTER_SPEED 5 // キャラクタの速さ
ddim character_x, CHARACTER_NUM // キャラクタの位置
ddim character_y, CHARACTER_NUM // キャラクタの位置
ddim target_x, CHARACTER_NUM // 移動先地点
ddim target_y, CHARACTER_NUM // 移動先地点
repeat CHARACTER_NUM
character_x( cnt ) = double( rnd( ginfo_winx - CHARACTER_SIZE ) )
character_y( cnt ) = double( rnd( ginfo_winy - CHARACTER_SIZE ) )
target_x( cnt ) = character_x( cnt )
target_y( cnt ) = character_y( cnt )
loop
command_num = -1 // 指令を出す対象のキャラクタナンバー
onclick gosub *label_onclick
*main
gosub *move
gosub *draw
wait 5
goto *main
*move
repeat CHARACTER_NUM
theta = atan( character_y( cnt ) - target_y( cnt ), target_x( cnt ) - character_x( cnt ) )
if absf( target_x( cnt ) - character_x( cnt ) ) > cos( theta ) * CHARACTER_SPEED {
character_x( cnt ) += cos( theta ) * CHARACTER_SPEED
} else {
character_x( cnt ) = target_x( cnt )
}
if absf( target_y( cnt ) - character_y( cnt ) ) > sin( theta ) * CHARACTER_SPEED {
character_y( cnt ) -= sin( theta ) * CHARACTER_SPEED
} else {
character_y( cnt ) = target_y( cnt )
}
loop
return
*draw
redraw 0
color 255, 255, 255 : boxf
gosub *draw_arrow
gosub *draw_character
gosub *draw_frame
redraw 1
return
*draw_character
repeat CHARACTER_NUM
hsvcolor cnt * 191 / CHARACTER_NUM, 255, 255
fillbox character_x( cnt ), character_y( cnt ), CHARACTER_SIZE
loop
return
*draw_arrow
repeat CHARACTER_NUM
if ( target_x( cnt ) != character_x( cnt ) ) | ( target_y( cnt ) != character_y( cnt ) ) {
hsvcolor cnt * 191 / CHARACTER_NUM, 255, 255
line target_x( cnt ), target_y( cnt ), character_x( cnt ), character_y( cnt )
}
loop
return
*draw_frame
if command_num >= 0 {
color
drawbox character_x( command_num ), character_y( command_num ), CHARACTER_SIZE
}
return
*label_onclick
// クリックしたキャラクタを探す
tmp = -1
repeat CHARACTER_NUM
dx = abs( mousex - character_x( cnt ) )
dy = abs( mousey - character_y( cnt ) )
if ( 0 <= dx ) & ( dx <= CHARACTER_SIZE / 2 ) & ( 0 <= dy ) & ( dy <= CHARACTER_SIZE / 2 ) {
tmp = cnt
break
}
loop
if tmp >= 0 : command_num = tmp : return
// キャラクタ以外をクリックした場合
if command_num >= 0 {
target_x( command_num ) = double( mousex )
target_y( command_num ) = double( mousey )
}
return
2007年8月16日木曜日
障害物のあるマップで視野を求める
フリーソフト超激辛ゲームレビュー様でHSPで作られたと思われる素晴らしいゲームが紹介されていました。Elonaというローグライクゲームです。詳しくは製作者様のサイトをご覧ください。
ローグ系はやったことも作ったこともあまり無いので処理内容の大半はよく分からないのですが、視野の計算がちょっと気になった&イメージが湧いたのでサンプルスクリプトを作成してみました。
左右非対称だったりと不完全ではありますが、充分実用に耐えうるのではないかと思われます。#const CHIP_SIZE 16 // マップチップの大きさ
#const WINX 320 // ウィンドウの大きさ
#const WINY 320
#const AREA_W WINX / CHIP_SIZE // マップの大きさ
#const AREA_H WINY / CHIP_SIZE
#const OBSTACLE_W 3 // 障害物の大きさ
#const OBSTACLE_H 2
//
// 数学関数
#define ctype max( %1, %2 ) ( %1 * ( %1 > %2 ) + %2 * ( %1 <= %2 ) )
#define ctype round( %1 ) double(strf("%%0.0f", %1))
//
// マップ描画用マクロ
#define draw_chip( %1, %2 ) boxf CHIP_SIZE * %1, CHIP_SIZE * %2, CHIP_SIZE * ( %1 + 1 ) - 2, CHIP_SIZE * ( %2 + 1 ) - 2
screen 0, WINX, WINY
randomize
sdim map, AREA_W * AREA_H
sdim shadow, AREA_W * AREA_H // 影を記録する変数。0なら明るい地点、それ以外は影。
gosub *make_blocks
onclick gosub *make_blocks
//
// メインループ
*main
if ( light_x != mousex / CHIP_SIZE ) | ( light_y != mousey / CHIP_SIZE ) {
renew = 1
}
if renew {
renew = 0
light_x = mousex / CHIP_SIZE
light_y = mousey / CHIP_SIZE
gosub *calc
gosub *draw
}
wait 2
goto *main
//
// 視野の計算
*calc
memset shadow, 2, AREA_W * AREA_H // 2...未検査
repeat AREA_H
y = cnt
dy = abs( y - light_y )
repeat AREA_W
if peek( shadow, y * AREA_W + cnt ) != 2 : continue
x = cnt
dx = abs( x - light_x )
// コメントアウトを解除すると、距離も考慮に入れるようになる
; if ( dx*dx+dy*dy > 48 ) {
; poke shadow, y * AREA_W + x, 1 // 1...検査済み(影)
; continue
; }
m = max( dx, dy )
repeat m
// 内分点の公式を使い、調査地点と光源の間にあるマス全てを調べる
_x = int(round(double( light_x * cnt + x * ( m - cnt ) ) / m))
_y = int(round(double( light_y * cnt + y * ( m - cnt ) ) / m))
if peek( map, _y * AREA_W + _x ) {
// 障害物を見つけた場合、今まで調べた地点はすべて影とする
repeat cnt + 1
_x = int(round(double( light_x * cnt + x * ( m - cnt ) ) / m))
_y = int(round(double( light_y * cnt + y * ( m - cnt ) ) / m))
poke shadow, _y * AREA_W + _x, 1 // 1...検査済み(影)
loop
break
}
poke shadow, _y * AREA_W + _x, 0 // 0...検査済み(明るい地点)
loop
loop
loop
return
//
// 各種描画処理
*draw
redraw 0
gosub *draw_map
gosub *draw_light
redraw 1
return
//
// マップを描画
*draw_map
color : boxf
repeat AREA_H
y = cnt
repeat AREA_W
if peek( map, y * AREA_W + cnt ) == 0 {
if peek( shadow, y * AREA_W + cnt ) {
color 192, 192, 192
} else {
color 255, 255, 255
}
draw_chip cnt, y
}
loop
loop
return
//
// 光源を描く
*draw_light
color 255, 128, 0
draw_chip light_x, light_y
return
//
// ブロックをランダムに配置
*make_blocks
memset map, 0, AREA_W * AREA_H
// 10個障害物を作成
repeat 10
poke map, rnd( AREA_W * AREA_H ), 1
loop
// 1個大きな障害物(OBSTACLE_WxOBSTACLE_H)を作成
x = rnd( AREA_W + 1 - OBSTACLE_W )
y = rnd( AREA_H + 1 - OBSTACLE_H )
repeat OBSTACLE_H
memset map, 1, OBSTACLE_W, ( y + cnt ) * AREA_W + x
loop
renew = 1
return
HHXモジュール 命令・関数から検索
前回はすべての命令・関数を対象としましたが、今回は特定の文字列を含む命令だけを抽出する方法を紹介します。
と言っても前回HHX_select_all()としていたところを、HHX_select_where(p1, p2, p3)とするだけです。メインの検索処理はモジュールが行ってくれます。
検索結果はキーワード適合度の高い順に並びます。検索キーワードが命令概要(C_SUMMARY)に載っている命令の方が説明(C_INST)に載っている命令よりも適合度が高くなります。
キーワード適合度の強さについては、hsp_db.hsp内のコメントをご覧ください。#include "../hsphelp/src/hhx_db.hsp"
#module
//
// 文字列の右側を半角スペースで埋める
#defcfunc add_spaces str sTarget, local iLength, local sResult
iStrlen = strlen( sTarget )
iLength = 30 - iStrlen
if iLength < 1 : iLength = 1
sdim sResult, iLength + iStrlen + 1
sResult = sTarget
memset sResult, ' ', iLength, iStrlen
return sResult
#global
// hsphelpディレクトリの存在を確認
chdir dir_exe
dirlist s, "hsphelp", 5
if stat == 0 : dialog "hsphelpディレクトリが見つかりません。", 1 : end
chdir dir_exe + "/hsphelp"
// HHXのデータベースをロード
HHX_init_load_db
if HHX_currentset_sum() ! HHX_diskset_sum() {
HHX_init_rebuild_db DBR_WRITEDB
} else {
HHX_init_extract_db
}
// 画面上にオブジェクトを配置
sSerch = "色" : sdim note, 10000 : notesel note
objsize 120, 24 : objmode 2 : font msgothic, 12
input sSerch, ginfo_winx - 120, 24
pos ginfo_winx - 120, 0
button gosub "検索", *serch
pos 0, 24
mesbox note, ginfo_winx, ginfo_winy - ginfo_cy
gosub *serch
onkey gosub *lbl_onkey
stop
// 入力ボックスでEnterを押したとき、検索を開始
*lbl_onkey
objsel -1
if ( wparam == 13 ) & ( stat == 0 ) : gosub *serch
return
// ある条件によってデータベースから検索を行い、その結果を列挙する
*serch
note = ""
db_num = HHX_select_where( sSerch, -1, -1 ) // 検索対象文字を解説などに含む命令・関数を列挙する
repeat db_num
c = HHX_get_next()
sLine = add_spaces( hhxdata( c, C_NAME ) ) + hhxdata( c, C_SUMMARY )
noteadd sLine
loop
objprm 2, note
return
2007年8月15日水曜日
2007年8月13日月曜日
HHXモジュール 命令・関数一覧を取得
おそらくあまり利用者のいないHHXモジュールについて、しばらく扱ってみようと思います。
HHXモジュールはHSファイルにアクセスする際、非常に強力な手段として利用することができます。HHXに付属されており、誰でも利用することができます。作者はsprocketさんです。
まずは以前も紹介した、命令・関数一覧の作成から。
データベースのロード手順はどんなスクリプトでも同じです。実際にこのスクリプトがHHX自身のスクリプトとほとんど同じであることを確認していただけると思います。
HHX_select_allを実行しただけでは名称順にソートされた状態ですが、HHX_order_by命令を利用することでグループ名・依存DLL名などによってソートできます。#include "../hsphelp/src/hhx_db.hsp"
#module
//
// 文字列の右側を半角スペースで埋める
#defcfunc add_spaces str sTarget, local iLength, local sResult
iStrlen = strlen( sTarget )
iLength = 30 - iStrlen
if iLength < 1 : iLength = 1
sdim sResult, iLength + iStrlen + 1
sResult = sTarget
memset sResult, ' ', iLength, iStrlen
return sResult
#global
// hsphelpディレクトリの存在を確認
chdir dir_exe
dirlist s, "hsphelp", 5
if stat == 0 : dialog "hsphelpディレクトリが見つかりません。", 1 : end
chdir dir_exe + "/hsphelp"
// HHXのデータベースをロード
HHX_init_load_db
if HHX_currentset_sum() ! HHX_diskset_sum() {
// HSファイルに何かしらの変更が加わったため、データベースを再構築
mes "HHXのデータベースをリビルドしています..."
HHX_init_rebuild_db DBR_WRITEDB // データベースを作成し、配列変数hhxdataxにロード
// より高速化を望むなら DBR_WRITEDB を DBR_READONLY としても良い
} else {
HHX_init_extract_db // 配列変数hhxdataxにメモリ上のデータをロード
}
mes "HHXのデータベースをロードしました。"
// データベースから命令・関数をひとつずつ取り出し、その名前を列挙する
db_num = HHX_select_all() // すべての命令・関数などを検索対象とする(ABC順)
; HHX_order_by C_GROUP // コメントを外すとグループ名でソート(昇順)
sdim buf, 16000
notesel buf
mes "命令一覧を作成します..."
repeat db_num
c = HHX_get_next() // 次の命令・関数などのナンバーを取得
sLine = add_spaces( hhxdata( c, C_NAME ) ) + hhxdata( c, C_SUMMARY )
noteadd sLine // ナンバー c で表現される命令・関数などの名前をnoteaddする
// C_SUMMARYなら命令・関数の概要を、C_INSTならその説明文を取得することができる(他はhhx_db.hspを参照)
loop
mes "命令一覧の作成を完了しました。"
objmode 2
font msgothic, 12
mesbox buf, ginfo_winx, ginfo_winy - ginfo_cy
stop
2007年8月12日日曜日
HSファイルからHTMLヘルプを作成する(2)
XHTMLに変わっている点を除き、恐らく機能的には以前同梱されていたヘルプと完全互換。
かなり大きめ(~1.5MB)のテキストデータを扱いますので、スペックに自信がない場合はawaitのコメントアウトをはずすか、他のアプリケーションを終了させた状態で実行することをオススメします。
グループを定義していない命令を想定していなかった問題を修正。
再現性を向上。現在再現性や利便性の向上を図り、改良中です。満足のいくものができたら公開します。v1.1を公開しました。
ウェブサイトで新バージョンの配布を行っています。
関連:HSファイルからHTMLヘルプを作成する// hsファイルからHTMLヘルプを作成
// 機能別索引を除くすべての索引も作成する
#include "../hsphelp/src/hhx_db.hsp"
#module
//
// 関数名・命令名からidを得る
#defcfunc get_id str name, local s
s = name
if ( peek( s, 0 ) == '#' ) : s = strmid( s, 1, strlen( s ) - 1 )
return "s_" + s
// 関数名・命令名からファイルの通し番号(独自に定義)を得る
// help_a.htmlを0、help_b.htmを1、…help_sp.htmを26とする
#defcfunc get_filenum str name, local s, local p
s = name
p = peek( s, 0 )
if ( 'A' <= p ) & ( p <= 'Z' ) : p -= 'A' - 'a'
if ( 'a' <= p ) & ( p <= 'z' ) {
return p - 'a'
} else {
return 'z' - 'a' + 1
}
//
// 通し番号からファイル名を得る
#defcfunc get_filename int num
if ( 0 <= num ) & ( num <= 'z' - 'a' ) {
return "help_" + strf( "%c", num + 'a' ) + ".htm"
} else {
return "help_sp.htm"
}
//
// 半角スペースで埋める
#defcfunc add_spaces str sTarget, local iLength, local sResult
iStrlen = strlen( sTarget )
iLength = 30 - iStrlen
if iLength < 1 : iLength = 1
sdim sResult, iLength + iStrlen + 1
sResult = sTarget
memset sResult, ' ', iLength, iStrlen
return sResult
#global
chdir dir_exe + "/hsphelp"
sdim buf, 10000
html_header = {"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">
<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"ja\" lang=\"ja\">
<head>
\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=Shift_JIS\" />
\t<meta http-equiv=\"Content-Language\" content=\"ja\" />
\t<link rel=\"stylesheet\" type=\"text/css\" href=\"hsphelp.css\" />
\t<title>HSP command help</title>
</head>
"}
gosub *load_db // HHXのDBからデータをロードする
gosub *make_html_files // HTMLファイルを作成する
gosub *make_frame_file // フレーム用HTMLファイルを作成する
gosub *make_ref_file // グループ別索引用HTMLを作成
gosub *make_css_file // CSSファイルを作成する
dialog "HTMLファイルの作成が完了しました。\nHTMLファイルを開きますか?", 2
if stat == 6 : exec "indexf.htm", 16
end
*load_db
HHX_init_load_db
if HHX_currentset_sum() ! HHX_diskset_sum() {
mes "HHXのデータベースをリビルドしています..." // HSファイルに何かしらの変更が加わったため、DBを再構築
HHX_init_rebuild_db DBR_WRITEDB
} else {
HHX_init_extract_db
}
mes "HHXのデータベースをロードしました。"
return
*init_file
// HTMLのヘッダを書き込む
sdim file, 20000
file = html_header + "<body>\n\t<h1>HSP command help</h1>\n"
file_offset = strlen( file )
return
*save_file
// HTMLファイルを保存する
file += "</body></html>"
file_offset += strlen( "</body></html>" )
bsave get_filename( file_type ), file, file_offset
return
*init_index
// 索引用HTMLのヘッダを書きこむ
sdim index, 100000 : index = html_header + "<body>\n\t<h1>HSP command help ABC順索引</h1><ul class=\"index_list\">\n" // 索引
sdim indexf, 100000 : indexf = html_header + "<body>\n\t<h1>索引</h1>\n\t<ul class=\"indexf_list\">\n" // フレーム用ミニ索引
indexf += "<p><a href=\"hspref.htm\" target=\"main\">グループ別索引</a></p>\n"
indexf += "<p><a href=\"hsppidx.htm\" target=\"main\">ABC順索引</a></p>\n"
index_offset = strlen( index )
indexf_offset = strlen( indexf )
return
*save_index
// 索引用HTMLを保存する
index += "\t</ul>\n</body></html>"
indexf += "\t</ul>\n</body></html>"
index_offset += strlen( "\t</ul>\n</body></html>" )
indexf_offset += strlen( "\t</ul>\n</body></html>" )
bsave "hsppidx.htm", index, index_offset
bsave "hsppidxf.htm", indexf, indexf_offset
return
*make_html_files
// HTMLファイルを作成する
mes "HTMLファイルの作成を開始..."
db_num = HHX_select_all() // すべての命令・関数を検索対象とする
file_type = get_filenum( "#" ) // 最初は記号で始まる命令用のファイル(help_sp.htm)からはじめる
file_name = get_filename( file_type )
gosub *init_file
gosub *init_index
repeat db_num
c = HHX_get_next()
db_name = hhxdata( c, C_NAME ) // 命令・関数名
id = get_id( db_name )
if file_type != get_filenum( db_name ) {
// 次のHTMLファイルへ移行
gosub *save_file
gosub *init_file
file_type = get_filenum( db_name )
file_name = get_filename( file_type )
}
// 索引
buf = "\t\t<li><a href=\"" + file_name + "#" + id + "\">" + add_spaces( db_name ) + hhxdata( c, C_SUMMARY ) + "</a></li>\n"
index += buf : index_offset += strlen( buf )
buf = "\t\t<li><a href=\"" + file_name + "#" + id + "\" target=\"main\">" + db_name + "</a></li>\n"
indexf += buf : indexf_offset += strlen( buf )
// 見出し(h2タグ)
buf = "\t<h2 id=\"" + id + "\" class=\"keyword_name\">" + db_name + "</h2>\n"
// パラメータ
buf += "\t<p class=\"prm\">" + add_spaces( db_name + " " + hhxdata( c, C_PRM ) ) + "[" + hhxdata( c, C_SUMMARY ) + "]</p>\n"
// パラメータ詳細
if hhxdata( c, C_PRM2 ) != "" {
buf += "\t\t<p class=\"prm_detail\">" + hhxdata( c, C_PRM2 ) + "</p>\n"
}
// 説明文
if hhxdata( c, C_INST ) != "" {
buf += "\t\t<h3>説明</h3><p class=\"inst\">" + hhxdata( c, C_INST ) + "</p>\n"
}
// 備考
if hhxdata( c, C_NOTE ) != "" {
buf += "\t\t<h3>備考</h3><p class=\"note\">" + hhxdata( c, C_NOTE ) + "</p>\n"
}
// 参照
if hhxdata( c, C_HREF ) != "" {
buf += "\t\t<h3>参照</h3><ul class=\"href\">"
i = 0 : l = strlen( hhxdata( c, C_HREF ) )
repeat
getstr s, hhxdata( c, C_HREF ), i, ' '
i += strsize
buf += "\t\t\t<li><a href=\"" + get_filename( get_filenum( s ) ) + "#" + get_id( s ) + "\">" + s + "</a></li>\n"
if l <= i : break
loop
buf += "\t\t</ul>"
}
// 水平線(次の項目との区切り)
buf += "\n\t<hr>\n\n"
// 変数に書き込み
file += buf
file_offset += strlen( buf )
; title str( double( cnt ) / db_num ) + "% finished..."
; await 1
loop
// 最後のファイルをディスクに保存
gosub *save_file
gosub *save_index
return
*make_ref_file
db_num = HHX_select_all()
HHX_order_by C_GROUP
sdim ref, 100000
ref = html_header + "<body>\n\t<h1>HSP command help グループ別索引</h1>\n"
ref += "\t<h2>(グループ未定義)</h2>\n\t\t<ul class=\"ref_list\">\n"
ref_offset = strlen( ref )
group_name = ""
repeat db_num
c = HHX_get_next()
buf = ""
db_name = hhxdata( c, C_NAME )
db_group = hhxdata( c, C_GROUP )
if group_name != db_group {
buf += "\t\t</ul>\n"
buf += "\t<h2>" + db_group + "</h2>\n\t\t<ul class=\"ref_list\">\n"
group_name = db_group
}
buf += "\t\t\t<li><a href=\"" + get_filename( get_filenum( db_name ) ) + "#" + get_id( db_name ) + "\">" + add_spaces( db_name ) + hhxdata( c, C_SUMMARY ) + "</a></li>\n"
ref += buf
ref_offset += strlen( buf )
loop
ref += "\t\t</ul>\n</body></html>"
ref_offset += strlen( "\t\t</ul>\n</body></html>" )
bsave "hspref.htm", ref, ref_offset
return
*make_frame_file
buf = html_header + {"\t<frameset cols=\"80%,*\">
\t\t<frame src=\"hspref.htm\" name=\"main\" />
\t\t<frame src=\"hsppidxf.htm\" name=\"sub\" />
\t</frameset>
\t<noframes>
\t\t<p>これはフレーム対応ブラウザ用のファイルです。<br />
\t\tフレームに対応したブラウザでご覧になるか、<a href=\"hsppidx.htm\">命令一覧</a>をご利用ください。</p>
\t</noframes>
</html>"}
bsave "indexf.htm", buf, strlen( buf )
return
*make_css_file
mes "CSSファイルの作成を開始..."
buf = {"body {
\tbackground-color : #f0e0d0 ;
}
h2 {
\tcolor : #000080 ;
\tfont-size : large ;
\tfont-weight : bold ;
\twhite-space : pre ;
}
h2.keyword_name {
\tfont-size : x-large ;
\tcolor : #504030 ;
\tfont-weight : bold ;
}
h3 {
\tfont-weight : bold ;
}
p.prm {
\tcolor : #000080 ;
\twhite-space : pre ;
\tmargin-left : 70px ;
\tfont-size : large ;
\tfont-weight : bold ;
\tfont-family : monospace ;
}
p.prm_detail {
\tcolor : #000080 ;
\tfont-size : small ;
\twhite-space : pre ;
\tmargin-left : 70px ;
}
p.inst {
\tmargin-left : 70px ;
\twhite-space : pre ;
}
p.note {
\tmargin-left : 70px ;
}
ul.href {
\tmargin-left : 70px ;
}
ul.index_list {
\tfont-size : large ;
}
ul.index_list li {
\twhite-space : pre ;
\tfont-family : monospace ;
\tmargin-bottom : 1ex ;
}
ul.indexf_list {
}
ul.ref_list {
\tfont-size : large ;
}
ul.ref_list li {
\twhite-space : pre ;
\tfont-family : monospace ;
\tmargin-bottom : 1ex ;
}"}
bsave "hsphelp.css", buf, strlen( buf )
return

