Jump to content


Photo

Gm Database System v10.3


  • Please log in to reply
86 replies to this topic

#21 benetonmovie

benetonmovie

    GMC Member

  • GMC Member
  • 1368 posts
  • Version:GM:Studio

Posted 27 November 2009 - 05:56 AM

Well in my case, I'm trying to make a complete engine where I can make tables on the fly using the exe, and not having to go into the gmk changing everything. Also, that code snippet I posted above is a good example on how to achieve that. I'm sure that other people will try to do the same thing, so it wouldn't hurt to add.

You're right. Well as you said the functions already exist, they're just not "public" (since I thought they would just be used internally) but they will be in the next version. :)
  • 0

#22 brod

brod

    Brian RODriguez

  • GMC Member
  • 2021 posts
  • Version:GM8

Posted 27 November 2009 - 06:11 AM

Um, a few problems I've encountered while editing.

db_entry_count(); has 3 arguments, but doesn't/shouldn't it return how many entries are in a single column? (So it should be (table id, column) I guess)

Also, I got this error

___________________________________________
ERROR in
action number 1
of Draw Event
for object obj_example:

In extension function db_entry_count:
In extension function db_entry_get_pos_all:
Error in code at line 14:
for (n = 0; n < ds_list_size(global.db_list_entries[argument0, colpos]); n += 1)

at position 65: Negative array index

I assume the error is a result of this code:
//draw the values
	for (m = 0; m < db_entry_count(table, n-1, 1); m += 1)
		{
		if (n == 0)
			{
			value = string(m);
			}
		else
			{
			value = db_entry_get_pos(table, n-1, m);
			}
		//if this entry is selected, change the color
		if (selectedrow == m)
			{
			draw_set_color(c_orange);
			if(selectedcol+1 == n && selectedcol>-1)draw_set_color(c_yellow);
			}
		draw_text(20 + n * 110, 76 + m * 22, value);
		draw_set_color(c_white);
		}

Edited by brod, 27 November 2009 - 06:15 AM.

  • 0

#23 benetonmovie

benetonmovie

    GMC Member

  • GMC Member
  • 1368 posts
  • Version:GM:Studio

Posted 27 November 2009 - 02:37 PM

As the helpfile says, the db_entry_count() function

Counts the number of entries where the value of the given column corresponds to the given value. Returns the number of entries found.


If you want to count the number of entries in a table (it will be the same for every column), use db_table_get_size().

Also can I please have your complete script so I know what the values of n are in this piece of code? Thank you!
  • 0

#24 brod

brod

    Brian RODriguez

  • GMC Member
  • 2021 posts
  • Version:GM8

Posted 27 November 2009 - 02:55 PM

Ah, that worked! Silly me :whistle:

I am having a very frustrating problem though, for some reason, this keeps on returning the default value when I try to put in a decimal value..
if (menu == 0)
		{
		//add entry
		var exe;
		exe = "db_entry_add(" +string(table)+ ", " +string(db_column_count(table))+ ", ";
		for(a=0;a<db_column_count(table);a+=1)
			{
			if(db_column_get_type(table, a)==0)
				{
				exe+= string(get_integer(db_column_get_name(table, a), 0)); //always return 0 when I put in any decimal value
				}
			else
				{
				exe+= '"'+get_string(db_column_get_name(table, a),db_column_get_default(table, a))+'"';
				}
			if(a<db_column_count(table)-1)exe+=", ";
			else exe+=")";
		}
		execute_string(exe);
		}

Edited by brod, 27 November 2009 - 02:56 PM.

  • 0

#25 benetonmovie

benetonmovie

    GMC Member

  • GMC Member
  • 1368 posts
  • Version:GM:Studio

Posted 27 November 2009 - 08:09 PM

Hey Brod, seems to be with the get_integer function... It doesn't take decimals! :whistle:
  • 0

#26 brod

brod

    Brian RODriguez

  • GMC Member
  • 2021 posts
  • Version:GM8

Posted 27 November 2009 - 10:53 PM

Posted Image

damn. Well that ruins my plans. Guess I'll have to come up with something else.

Edited by brod, 27 November 2009 - 11:59 PM.

  • 0

#27 benetonmovie

benetonmovie

    GMC Member

  • GMC Member
  • 1368 posts
  • Version:GM:Studio

Posted 27 November 2009 - 11:12 PM

Well there are other ways... for instance you could use get_string and convert the string to a real. Of course that would need some error-checking but it isn't hard. :whistle:
  • 0

#28 brod

brod

    Brian RODriguez

  • GMC Member
  • 2021 posts
  • Version:GM8

Posted 28 November 2009 - 12:00 AM

Yeah I'll just do something easier. (I was trying to make a "% per use", but instead I'll just make it "Uses to master". Same difference)
  • 0

#29 benetonmovie

benetonmovie

    GMC Member

  • GMC Member
  • 1368 posts
  • Version:GM:Studio

Posted 28 November 2009 - 01:12 AM

Lol okay. Funny how you edited your post after I replied to it.
  • 0

#30 brod

brod

    Brian RODriguez

  • GMC Member
  • 2021 posts
  • Version:GM8

Posted 28 November 2009 - 01:55 AM

Had to add the image :whistle:
But yeah, I'm done bickering and annoying you, thanks again for the awesome extension, GREAT IDEA!
  • 0

#31 Recreate

Recreate

    Furry

  • GMC Member
  • 2928 posts
  • Version:GM8

Posted 28 November 2009 - 04:25 AM

Well. I would just use .php files to manipulate my database with netread, But this is still neat. :whistle:
  • 0

#32 benetonmovie

benetonmovie

    GMC Member

  • GMC Member
  • 1368 posts
  • Version:GM:Studio

Posted 28 November 2009 - 07:29 AM

Thanks!

I have the pleasure to announce the release of VERSION 10! :whistle: See the change log below and download on first post!

NEW in version 10.0
- Major change in the columns system to enhance flexibility: columns now have ID's, which you can save as variables to use in function calls (you can still use the column name directly, but not the position)
- New functions db_column_insert(), db_column_destroy(), many new db_column_get_* functions
- Ability to sort by more than one column with the new db_table_sort_multiple() function
- Improved the example, now has drag & drop and the ability to add, insert and destroy columns
- Solved a bug in the shuffle function, that prevented it from working under certain conditions
- Added arguments to change the size of the drawing in db_table_draw()
- Changed a bit the bahevior of the function db_table_read()
- Optimized a few scripts
- Shorter and cleaner argument names in the script editor help panel
  • 0

#33 brod

brod

    Brian RODriguez

  • GMC Member
  • 2021 posts
  • Version:GM8

Posted 28 November 2009 - 02:42 PM

GREAT!

Edited by brod, 28 November 2009 - 03:09 PM.

  • 0

#34 Universal_X

Universal_X

    GMC Member

  • New Member
  • 126 posts

Posted 07 December 2009 - 12:14 PM

This looks great!

But could you put in the table data in a .ini file?
  • 0

#35 benetonmovie

benetonmovie

    GMC Member

  • GMC Member
  • 1368 posts
  • Version:GM:Studio

Posted 07 December 2009 - 11:20 PM

Of course you can, by transforming the table into a string with the function db_table_write().
  • 0

#36 benetonmovie

benetonmovie

    GMC Member

  • GMC Member
  • 1368 posts
  • Version:GM:Studio

Posted 26 December 2009 - 05:35 AM

I would like to say that this extension is 100% compatible with GM8 (at least from a quick test & review). :snitch:
  • 0

#37 Rafferty97

Rafferty97

    GMC Member

  • New Member
  • 268 posts

Posted 10 January 2010 - 02:29 AM

cool, the gex looks very promising. I will probabily use it when I do a project requiring databases. Just from looking at this topic, I can give it 8/10.

One thing though, is it fast?

- Alex

EDIT: Awesome, compatible with GM8 ;)!

Edited by Rafferty97, 10 January 2010 - 02:31 AM.

  • 0

#38 benetonmovie

benetonmovie

    GMC Member

  • GMC Member
  • 1368 posts
  • Version:GM:Studio

Posted 10 January 2010 - 03:15 PM

One thing though, is it fast?

Speed shouldn't be a problem!
  • 0

#39 benetonmovie

benetonmovie

    GMC Member

  • GMC Member
  • 1368 posts
  • Version:GM:Studio

Posted 14 March 2010 - 09:08 PM

Gentle bump... Any suggestions for future updates?
  • 0

#40 Antonio_moder

Antonio_moder

    GMC Member

  • New Member
  • 17 posts

Posted 05 April 2010 - 09:37 AM

Thank you very much benetonmovie ^_^
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users