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 - Power with Strings & Arrays

Power with Strings & Arrays

Discuss topics that apply across the products, such as the PocketC language, or development in general

Postby Gazza on Wed Jan 16, 2002 4:35 am

I have created this topic to build a wealth of programming routines to sort and remove and change data,

Ok these are the sort I things I would like to achive,

*Remove an array from an array list, then re-shuffle the array so that it closes up the gap.

*Insert data into an array in a particular place

* Create an Array and mix up the data

// More to Come // I am working out these problems but would appreciate any help, Thanks everyone.....



Edited by - Gazza on 01/15/2002 22:37:50
Gazza
 
Posts: 146
Joined: Sat Jan 12, 2002 1:56 am
Location: United Kingdom

Postby guy on Wed Jan 16, 2002 11:09 am

If you're interested in code that manages "arrays" that can have elements removed and reordered then take at look at my linked list/tree library. You can download the source from the pcform page (link in sig). Although this was written for the CE version of PocketC it should work with both versions (may require some small tweaking for Palm).

It allows you to create collections of items. Items can have several fields and can be reordered or deleted. Items can own other collections of items. Items have constructors and destructors. There are functions to walk the lists and call a function of your choice for each item (like enumerators).

The data structures that it manages are very heavily used in pcform and I've not had any reports of bugs or memory leakage in the code.

It would be easy to add a quicksort function to the library so that a list could be sorted automatically, calling a user defined comparison function for each item.


Guy
[url]mailto:pcform@pcform.net[/url]
http://www.pcform.net
PocketC CE API interface: http://www.networkdynamics.net/pcktceapi.zip


Edited by - guy on 01/16/2002 05:12:31
Guy
[url]mailto:pcform@pcform.net[/url]
http://www.pcform.net
PocketC CE API interface: http://www.networkdynamics.net/PCForm.html#library
PCForm and CE API forum: http://www.networkdynamics.net/forum
guy
 
Posts: 879
Joined: Thu Dec 07, 2000 8:58 am
Location: United Kingdom

Postby Gazza on Thu Jan 17, 2002 9:08 am

It would not install onto the pc, I really want to stay away from the api, I would like to write native code, but I am not quite that far yet & can you write Native Libarys using pocket c, I could possible do most of these tasks, its just the @[] does not work, I have tried this and just get an error

str @[1] = 'W';
Gazza
 
Posts: 146
Joined: Sat Jan 12, 2002 1:56 am
Location: United Kingdom

Postby Gazza on Fri Jan 18, 2002 5:05 am

Ok Here The First to Randomize a String

// Random String

string person[3];
string new[6];

nxt(int x, string hold) {
string tmp; int t,y; t=x;
while(x) {
new[x-1]=substr(hold,x-1,1);
x--; }

hold="";
while(t) {
y=random(t--);
tmp=new[t];
new[t]=new[y];
new[y]=tmp;
hold=hold+new[t]; }
puts(hold); }

main() {
int x;
string hold;
person[0]="Gareth";
hold = person[0];
x = strlen(hold);
nxt(x,hold); }

This uses Joe Stadolnik Algo to Randomize the Array, I am working on this program with pointers to reduce the code.
Gazza
 
Posts: 146
Joined: Sat Jan 12, 2002 1:56 am
Location: United Kingdom

Postby Gazza on Fri Jan 18, 2002 7:45 am

ok here is the same program using pointers, not sure why ret = ctostr(ptr); does not return all data from the pointer, hence the loop.

// Rand String

string per[3];
pointer ptr;

main() {
string str,tmp,ret;
int len,y,i;
per[0]="Gareth";
str = per[0];
len = strlen(str)+1;
ptr = malloc(len);
settype(ptr, len, 'c');
strtoc(str, ptr);

while(len) {
i=random(len--);
tmp=ptr[len];
ptr[len]=ptr[i];
ptr[i]=tmp; }

// ret = ctostr(ptr);
for(y=0; y<strlen(str)+1; y++)
{puts(ptr[y]); }
free(ptr); }
Gazza
 
Posts: 146
Joined: Sat Jan 12, 2002 1:56 am
Location: United Kingdom


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 2 guests

cron