Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3368: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3370: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3371: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3372: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
OrbWorks Community Forum • View topic - CtableDB - How to use?

CtableDB - How to use?

Discuss PocketC for Palm OS (including Desktop Edition)

Postby chrisfoster on Tue Mar 20, 2001 6:55 pm

How to you find out which record the user has selected on a tableDB in CControls? I tried to use the value returned by Cgercursel in Cgetfield, but that didn't seem to work.

example code
<pre id=code><font face=courier size=2 id=code>
int index;string x;
index=Cgetcursel(table);
x=Cgetfield(table,index);
puts(x);
</font id=code></pre id=code>

In the above, does x have to be a pointer?
chrisfoster
 
Posts: 10
Joined: Tue Mar 20, 2001 6:50 pm

Postby stephane on Wed Mar 21, 2001 2:06 am

You only need Cgetcursel(), which returns the row (record) number that is currently selected within the tableDB control.

Cgetfield() will return the contents of the field within a given row.

There is no automatic way (at least not yet...) to get which field was selected by the user. You could do that yourself by getting the penx/peny after a row selection, and calculating it.

hth,


St?ɬ©phane
Stéphane
stephane
 
Posts: 71
Joined: Fri Jan 12, 2001 3:16 am
Location: Canada

Postby chrisfoster on Fri Mar 23, 2001 12:37 am

but Cgetfield doesn't always work! Sometimes, it will just give me a 0 or something like that.
chrisfoster
 
Posts: 10
Joined: Tue Mar 20, 2001 6:50 pm

Postby stephane on Fri Mar 23, 2001 1:31 am

I should have been more explicit in my initial reply.. your code example is <i>not</i> correct. It should look more like this:
<pre id=code><font face=courier size=2 id=code>row=Cgetcursel(table);
if(row != -1 ) {
field1=Cgetcontent(table); // equivalent to Cgetfield(table, 0)
field2=Cgetfield(table, 1);
field3=Cgetfield(table, 2);
// etc...
}
</font id=code></pre id=code>

Cgetcursel() is only used to get the index, or row, already selected by the user, and in my example I used it to make sure something was actually selected. That is <i>all</i> it's used for. In other words, Cgetfield() does not need Cgetcursel() at all.. it uses whatever row is selected by the user, or whatever you select using C<i>set</i>cursel().

Also, Cgetfield() returns a <i>field</i>, or <i>column</i>, within the row; do not be misled by the original docs written for Ccontrols.
For Cgetfield(), it says that it gets a row; it does <i>not</i>. In several cases, the documentation says row when it means <i>column</i>. Strangely, the docs for Cgetcontent are correct, and state that it retrieves the first field in the row...
The author's mother tongue is German, which may explain some of the confusion <img src=icon_smile.gif border=0 align=middle>.

Hope this clarifies, if not, ask again.


St?ɬ©phane
Stéphane
stephane
 
Posts: 71
Joined: Fri Jan 12, 2001 3:16 am
Location: Canada

Postby chrisfoster on Mon Mar 26, 2001 10:43 pm

OK, if I send the index returned by Cgetcursel() into dbseek, then it will select the right record, correct?
chrisfoster
 
Posts: 10
Joined: Tue Mar 20, 2001 6:50 pm

Postby stephane on Tue Mar 27, 2001 1:49 am

Yes, you are right, although the correct function would be dbrec(), not dbseek().

So, set dbrec() to the index returned by Cgetcursel(), and you can retrieve the entire record of information requested by a user, for example.

Seems that's the easiest way to explain, but in my last reply, it looks like I lost track that we were actually talking about database access, and not just the Ctable() control.. <img src=icon_smile.gif border=0 align=middle>

Cheers,


St?ɬ©phane
Stéphane
stephane
 
Posts: 71
Joined: Fri Jan 12, 2001 3:16 am
Location: Canada

Postby chrisfoster on Tue Mar 27, 2001 7:40 pm

Thanks for your help - Chris
chrisfoster
 
Posts: 10
Joined: Tue Mar 20, 2001 6:50 pm


Return to PocketC for Palm OS

Who is online

Users browsing this forum: No registered users and 1 guest

cron