Re: Trouble with Database(EDS)

new topic     » goto parent     » topic index » view thread      » older message » newer message

Ok I got something working almost. It display 0 when it should show the correct size and I'm not sure how I would add more entries into 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 = repeat(0,256) 
integer idkey 
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") 
	end if 
 end if 
end if 
if db_select_table(GameTable) != DB_OK then 
	if db_create_table(GameTable) != DB_OK then 
		puts(1,"Table not created!\n") 
	end if 
end if 
game_data = {"Uncharted 4","Naughty Dog",{50},"Single Player","Multiplayer"} 
game_id = hash(game_data[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") 
		printf(1,"Game ID: %d added.\n",game_id) 
	end if 
		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: %d\n",{game_data[3]}) --shows up as 0 currently 
			printf(1,"Single Player: %s\n",{game_data[4]}) 
			printf(1,"Multiplayer: %s\n",{game_data[5]}) 
		end if 
end if 
new topic     » goto parent     » topic index » view thread      » older message » newer message


Quick Links

User menu

Not signed in.

Misc Menu