Re: Trouble with Database(EDS)

new topic     » goto parent     » topic index » view thread      » older message » newer message
_tom said...

change this one line

 
			printf(1,"Size: %d\n", game_data[3] ) --was shows up as 0 currently  
			                                       -- now 50 

_tom

Thanks Tom. Ok I mananged to add multiple entries. Is there a GUI way of viewing the database?

include std/eds.e 
include std/get.e 
include std/map.e 
 
without type_check 
 
sequence GameDB = "GameDB.edb" 
sequence GameTable = "Game" 
atom game_id 
sequence game_data  
integer idkey,idkey2 
sequence game_data2 
atom game_id2 
 
 
if db_select(GameDB) != DB_OK then 
	if db_open(GameDB,DB_LOCK_NO) != DB_OK then 
	if db_create(GameDB,DB_LOCK_NO) != DB_OK then 
				puts(1,"Could not create database!\n") 
		abort(1) 
	end if 
 end if 
 	db_select(GameDB) 
end if 
 
if db_select_table(GameTable) != DB_OK then 
	if db_create_table(GameTable) != DB_OK then 
		puts(1,"Table not created!\n") 
		abort(1) 
	end if 
	db_select_table(GameTable) 
end if 
 
game_data = {"Uncharted 4: A Thief's End","Naughty Dog",{50},"YES","YES Network 2-11"} 
game_id = hash(game_data[1..3],GameTable) 
 
game_data2 = {"Dragon's Crown Pro","Vanillware",{5.6},"YES","YES - Local/Network 2-4"} 
game_id2 = hash(game_data2[1..3],GameTable) 
 
idkey = db_find_key(game_id) 
if idkey < 0 then 
	if db_insert(game_id,{game_data}) != DB_OK then 
		puts(1,"Could not insert game!\n") 
		abort(1) 
	else 
		printf(1,"Game ID: %d added.\n",game_id) 
	end if 
	else 
		game_data = db_record_data(idkey) 
		printf(1,"Game ID: %d\n",game_id) 
		if length(game_data) = 1 then 
			game_data = game_data[1] 
			printf(1,"Title: %s\n",{game_data[1]}) 
			printf(1,"Developer: %s\n",{game_data[2]}) 
			printf(1,"Size: %f GB\n",game_data[3]) 
			printf(1,"Single Player: %s\n",{game_data[4]}) 
			printf(1,"Multiplayer: %s\n",{game_data[5]}) 
		end if 
end if 
 
puts(1,"\n") --to add space between entries 
 
idkey2 = db_find_key(game_id2) 
if idkey2 < 0 then 
	if db_insert(game_id2,{game_data2}) != DB_OK then 
		puts(1,"Could not insert game!\n") 
		abort(1) 
	else 
		printf(1,"Game ID: %d added.\n",game_id2) 
	end if 
	else 
		game_data2 = db_record_data(idkey2) 
		printf(1,"Game ID: %d\n",game_id) 
		if length(game_data2) = 1 then 
			game_data2 = game_data2[1] 
			printf(1,"Title: %s\n",{game_data2[1]}) 
			printf(1,"Developer: %s\n",{game_data2[2]}) 
			printf(1,"Size: %f GB\n",game_data2[3]) 
			printf(1,"Single Player: %s\n",{game_data2[4]}) 
			printf(1,"Multiplayer: %s\n",{game_data2[5]}) 
		end if 
end if 
 
db_close() 
new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu