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 - Whats the best way to do this?

Whats the best way to do this?

Discuss PocketC for Palm OS (including Desktop Edition)

Postby Velvis on Thu Apr 12, 2001 7:39 pm

I have a database and each record has 10 fields. I have been reading them by doing a loop and assign each read field into an array.

ie
data[ndata++] =dbread('s');

which leaves me with:
data[0]="Joe Shmoe"
data[1]="123 Main Street"
etc...

This works fine when I want to display an individual record set (all ten fields) at one time.

What I need to do is break the data into groups by fields. (ie I need an array filled with all the peoples names only, followed by an array filled with addresses, etc..

Example:
data[0]="Joe Shmoe"
data[1]="Fred Flintstone"
data[3]="Barney Rubble"

I am not sure how or whats the best way to do this, so any help would be appreciated!

Thanks
Velvis
 
Posts: 226
Joined: Mon Dec 11, 2000 2:32 am

Postby slmiller on Thu Apr 12, 2001 9:05 pm

In order to do this you need a very structured database. For instance lets say your database goes something like this
<pre id=code><font face=courier size=2 id=code>
(1)Joe Shmoe
(2)123 Main Street
(3)John Doe
(4)987 W. 34th Street
etc...
</font id=code></pre id=code>
In this case, all odd records are names and all even records are addresses. So, you have your loop iterate through the code by odd numbers for the names and by even numbers for the addresses. Hope this helps

Duct tape is The Force. It has a light side, a dark side, and it holds the world together.
"To beer. The cause of, and solution to, all of life's problems" - Homer Simpson
slmiller
 
Posts: 63
Joined: Mon Jan 08, 2001 6:09 pm
Location: USA

Postby Velvis on Thu Apr 12, 2001 10:52 pm

I can't do that because I need to be able to access it one whole record at a time (as it is now), in addition to accessing all of a particular field.

So if I switched to your database style, I would have a similar problem anyways.
Velvis
 
Posts: 226
Joined: Mon Dec 11, 2000 2:32 am

Postby wolfgang on Thu Apr 12, 2001 11:06 pm

Hello,

you could use a two-dimensional array. I have a source code library on my webpage that makes defining/using one really easy:

http://pages.prodigy.net/gwen.and.wolfgang/

Go to the Resources section.
Then you can define a 10 x N array of strings (10 is the number of fields in one record, N is the number of records you want to read).

Wolfgang
Composing music on the PocketPC! - http://www.pdamusician.com
wolfgang
 
Posts: 281
Joined: Tue Dec 12, 2000 4:22 am
Location: USA

Postby wolfgang on Thu Apr 12, 2001 11:06 pm

Hello,

you could use a two-dimensional array. I have a source code library on my webpage that makes defining/using one really easy:

http://pages.prodigy.net/gwen.and.wolfgang/

Go to the Resources section.
Then you can define a 10 x N array of strings (10 is the number of fields in one record, N is the number of records you want to read).

Wolfgang
Composing music on the PocketPC! - http://www.pdamusician.com
wolfgang
 
Posts: 281
Joined: Tue Dec 12, 2000 4:22 am
Location: USA

Postby Velvis on Fri Apr 13, 2001 1:16 am

Isnt that only for the WinCE version of PocketC?
Velvis
 
Posts: 226
Joined: Mon Dec 11, 2000 2:32 am

Postby slmiller on Fri Apr 13, 2001 1:38 am

I have used the library Wolfgang is speakiing of, and it works on the Palm. It works quite well in fact. I used it for a encryption systemt that used a 3 dimensional array. It should do the trick.

Duct tape is The Force. It has a light side, a dark side, and it holds the world together.
"To beer. The cause of, and solution to, all of life's problems" - Homer Simpson
slmiller
 
Posts: 63
Joined: Mon Jan 08, 2001 6:09 pm
Location: USA

Postby jstadolnik on Fri Apr 13, 2001 1:55 am

If you are using the toolbox lib, the Array fuction will also do the job. (Which BTW is based on Wolfgang's code.)

Joe
jstadolnik
 
Posts: 1741
Joined: Wed Dec 06, 2000 3:34 am
Location: USA

Postby Velvis on Fri Apr 13, 2001 4:19 pm

When I compile the code for the Palm I get an error with the following line:(it chokes on strchr, is there an equivlent Palm PocketC command?
if ((comma_pos = strchr (*ps, ',')) > 0)
Velvis
 
Posts: 226
Joined: Mon Dec 11, 2000 2:32 am

Postby wolfgang on Fri Apr 13, 2001 9:13 pm

strchr searches for a character in a string and returns its position (starting with 0 for the first character, and -1 if it did not find any). You can use strstr on the Palm version instead.

Wolfgang
Composing music on the PocketPC! - http://www.pdamusician.com
wolfgang
 
Posts: 281
Joined: Tue Dec 12, 2000 4:22 am
Location: USA


Return to PocketC for Palm OS

Who is online

Users browsing this forum: No registered users and 6 guests

cron