〜 スクリプト 〜
packfileを作成

PackFileとは、実行ファイルを作成する時、どのファイルを埋め込むかを指定するアレです。
パックされたファイルの実体はDPMファイルと呼ばれるものですが、
PackFile自体は、メモ帳などのテキストエディタで開くことの出来るテキストファイルです。
開いてみると、1行を1データとして、パックするファイルのパスが記述されています。
自分でスクリプトエディタを作成する場合、HSPCMP.DLL(common/hspcmp.as)を用いることで実現できます。
スクリプトのコンパイルや実行ファイルの作成は、このDLLに命令があるのですが、
PackFileの作成は、既に記述した通り、単純なテキストファイルなので命令が用意されていません。
もし、スクリプトエディタを作成しようと考えているものの、
PackFileの作成方法が分からない場合は、下記を参考にしてみてはいかがでしょうか?
	
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
	onerror goto *error
	sdim dir, 256
	sdim list1, 4
	sdim list2, 4
	screen 0, 400, 380
	title "パックファイルマネージャ"
	color 220, 220, 220 : boxf : color
	font "MS ゴシック", 12 : objmode 2
	dir = curdir
	objsize 120, 25
	pos  10,  10 : input dir, 240, 25
	pos 270,  10 : button "ディレクトリ移動", *seldir
	objsize 380, 40
	pos  10,  45 : listbox index.0, , list1
	pos  10, 215 : listbox index.1, , list2
	objsize 60, 25
	pos  10, 180 : button "追加", *add
	pos  80, 180 : button "削除", *del
	pos 150, 180 : button "全削除", *alldel
	objsize 80, 25
	pos 220, 180 : chkbox "暗号化する", angou
	pos 310, 350 : button "作成", *make
	goto *getitem

*error
	dialog "操作に誤りがあります。", 1
	stop

*update
	objprm 2, list1
	objprm 3, list2
	stop

*seldir
	chdir dir // カレントフォルダの変更

*getitem
	dirlist list1, "*.*", 1
	goto *update

*add
	// 選択フォルダ文字列を代入
	dir = curdir
	// 選択アイテムを取得
	notesel list1
	noteget item, index.0
	strlen len, dir : strmid chk, dir, len - 1, 1
	if chk ! "\\" : item = "\\" + item
	item = curdir + item
	// 既に選択済かをチェックする
	notesel list2
	notemax rows
	repeat rows
		noteget chk, cnt
		if chk = item : poke item : break // 選択済
	loop
	if item = "" : stop
	// アイテムをセットする
	if angou : chk = "+" : else : chk = ""
	noteadd chk + item, -1
	goto *update

*del
	if index.1 < 0 : goto *error
	notesel list2
	noteget item, index.1
	notedel index.1
	goto *update

*alldel
	poke list2 // クリア
	goto *update

*make
	notesel list2
	notesave exedir + "\\packfile"
	dialog "packfileを作成しました"
	stop
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
	onerror gosub *error
	sdim dir, 256
	sdim list1, 4
	sdim list2, 4
	screen 0, 400, 380
	title "パックファイルマネージャ"
	color 220, 220, 220 : boxf : color
	font "MS ゴシック", 12 : objmode 2
	dir = dir_cur
	objsize 120, 25
	pos  10,  10 : input dir, 240, 25
	pos 270,  10 : button gosub "ディレクトリ移動", *seldir
	objsize 380, 40
	pos  10,  45 : listbox index.0, , list1
	pos  10, 215 : listbox index.1, , list2
	objsize 60, 25
	pos  10, 180 : button gosub "追加", *add
	pos  80, 180 : button gosub "削除", *del
	pos 150, 180 : button gosub "全削除", *alldel
	objsize 80, 25
	pos 220, 180 : chkbox "暗号化する", angou
	pos 310, 350 : button gosub "作成", *make
	gosub *getitem
	stop

*error
	dialog "操作に誤りがあります。", 1
	return

*update
	objprm 2, list1
	objprm 3, list2
	return

*seldir
	chdir dir // カレントフォルダの変更

*getitem
	dirlist list1, "*.*", 1
	gosub *update
	return

*add
	// 選択フォルダ文字列を代入
	dir = dir_cur
	// 選択アイテムを取得
	notesel list1
	noteget item, index.0
	if strmid(dir, strlen(dir) - 1, 1) ! "\\" : item = "\\" + item
	item = dir_cur + item
	// 既に選択済かをチェックする
	notesel list2
	repeat notemax
		noteget chk, cnt
		if chk = item : poke item : break // 選択済
	loop
	if item = "" : return
	// アイテムをセットする
	if angou : chk = "+" : else : chk = ""
	noteadd chk + item, -1
	gosub *update
	return

*del
	if index.1 < 0 : goto *error
	notesel list2
	noteget item, index.1
	notedel index.1
	gosub *update
	return

*alldel
	poke list2 // クリア
	gosub *update
	return

*make
	notesel list2
	notesave dir_exe + "\\packfile"
	dialog "packfileを作成しました"
	return