INI

 これはINI文のサンプルです。
 INIファイルが予めないとエラーになります。

-- iniテスト ini.lua
-- 書き込むiniファイルはtest.ini
 
test = INI.load("test.ini", VRAM)
 
while not Stylus.doubleClick do
 
 	Controls.read()
 	startDrawing()
	screen.print(SCREEN_UP, 8 * 1 + 20,20, "ini Variable")
	screen.print(SCREEN_UP, 8 * 4 + 20,28, "SET")
 	screen.print(SCREEN_UP,  8 * 3 + 20,60, "UP")
 	screen.print(SCREEN_UP,  8 * 1 + 20,80, "<-")
	screen.print(SCREEN_UP,  8 * 4 + 20,80, "->")
 	screen.print(SCREEN_UP,  8 * 2 + 20,100, "DOWN")
 
	screen.print(SCREEN_UP,  8 * 16 + 20,20, "ini")
	screen.print(SCREEN_UP,  8 * 16 + 20,28, "Save/Read")
 
	screen.print(SCREEN_UP,  8 * 16 + 20,80, "A Read")
 	screen.print(SCREEN_UP,  8 * 14 + 20,100, "B Save")
 
	screen.print(SCREEN_DOWN,  8 * 6 ,120, "Pen touch Double Click Exit")
 
	if Keys.newPress.Up or Keys.held.Up then
		test["test"]["test1"] = tostring("UP_KEY")
		test["test"]["test2"] = tostring("up_aaa")
		test["test"]["test3"] = "UP"
		test["test"]["test4"] = 123
		test["test"]["test5"] = "!#"
	end
	if Keys.newPress.Left or Keys.held.Left then
		test["test"]["test1"] = tostring("LEFT_KEY")
		test["test"]["test2"] = tostring("left_aaa")
		test["test"]["test3"] = "LEFT"
		test["test"]["test4"] = 234
		test["test"]["test5"] = "$%&"
	end
	if Keys.newPress.Right or Keys.held.Right then
		test["test"]["test1"] = tostring("RIGHT_KEY")
		test["test"]["test2"] = tostring("right_aaa")
		test["test"]["test3"] = "RIGHT"
		test["test"]["test4"] = 345
		test["test"]["test5"] = "'()"
	end
	if Keys.newPress.Down or Keys.held.Down then
		test["test"]["test1"] = tostring("DOWN_KEY")
		test["test"]["test2"] = tostring("down_aaa")
		test["test"]["test3"] = "DOWN"
		test["test"]["test4"] = 456
		test["test"]["test5"] = "=~|"
	end
 
	if Keys.newPress.A or Keys.held.A then
		test = INI.load("test.ini", VRAM)
	end
	if Keys.newPress.B or Keys.held.B then
		INI.save("test.ini", test)
	end
 
	screen.print(SCREEN_DOWN, 50, 8 * 1, "[TEST]test1  " .. test["test"]["test1"], Color.new(31, 0, 0))
	screen.print(SCREEN_DOWN, 50, 8 * 2, "[TEST]test2  " .. test["test"]["test2"], Color.new(31, 0, 0))
	screen.print(SCREEN_DOWN, 50, 8 * 3, "[TEST]test3  " .. test["test"]["test3"], Color.new(31, 0, 0))
	screen.print(SCREEN_DOWN, 50, 8 * 4, "[TEST]test4  " .. test["test"]["test4"], Color.new(31, 0, 0))
	screen.print(SCREEN_DOWN, 50, 8 * 5, "[TEST]test5  " .. test["test"]["test5"], Color.new(31, 0, 0))
 
 	stopDrawing()
 
end
 
test = NIL
 

実行例

test.iniの初期内容を同じフォルダーに置きます。





タグ:

+ タグ編集
  • タグ:
最終更新:2011年01月07日 10:09
ツールボックス

下から選んでください:

新しいページを作成する
ヘルプ / FAQ もご覧ください。
添付ファイル